Handling Array Fields

Nov 30, 2005

Hi,

I have a linked db in my sql database and one of the fields I am trying to query is an array. Is there a way to only select 1 element of the array instead of all the values. When I do the select in t-sql for the linked server I get a semi-colon list of values.

The linked server db has a function called pro_element(fieldname,1,1) which will return 1 array element, but t-sql obviously won't recognize this. Is there something similar? Or can I tell t-sql to pass this to the DB even if it doesn't know the command?

Thanks for any help,
Scott

View 6 Replies


ADVERTISEMENT

Pass Fields As Array To Custom Function?

May 23, 2007

I created a custom function that accepts an array of strings as a input. I need to pass several fields from the dataset to this function as an array. How can I do this?

View 3 Replies View Related

Handling Null Fields With Three-tier Architecture

Nov 28, 2006

I using Visual Web Designer Express (with Visual Basic), with a SQL Server 2000 database.   I have a prototype application running satisfactorily using code that builds queries, but I'm now trying to rebuild the application "properly" using three-tier architecture.  I have been following the principles of Scott Mitchell's tutorials.  I have created an database .xsd with a table adaptor, and replaced the rather grotty query-building code in the business layer with better code referencing the table adaptor.   Thus where the first version had code: -
        Dim queryString As String = "SELECT * FROM NZGDB_User WHERE USRid = '" & Userid & "'"        Dim message As String = ""        Dim Found As Boolean = False        Try            Using connection As New SqlConnection(GDB_AppSettings.Connection)                Dim command As New SqlCommand(queryString, connection)                connection.Open()
                Dim reader As SqlDataReader = command.ExecuteReader()
                If reader.Read() Then                    Found = True                    _USRid = reader("USRid")                    _USRPassword = reader("USRPassword")                    _USREmail = reader("USREmail")                    _USRTitle = reader("USRTitle")                    _USRName = reader("USRName")                    _USRRole = reader("USRRole")                    If IsDBNull(reader("USRAgreedConditions")) = False Then                        _USRAgreedConditions = reader("USRAgreedConditions")                    End If                End If                reader.Close()            End Using        Catch ex As Exception            If Left(Err.Description, 68) = "An error has occurred while establishing a connection to the server." Then                Return "Cannot open database to logon"            Else                Return Err.Description            End If        End Try
the new version is much more elegant: -
        Dim taUser As New NZGDBTableAdapters.NZGDB_UserTableAdapter()
        Dim tbUser As NZGDB.NZGDB_UserDataTable = taUser.GetUserByUserid(userid)        If tbUser.Count <> 1 Then   '   Anything other than 0 or 1 should be impossible            Return "User not found"        End If
        Dim trUser As NZGDB.NZGDB_UserRow = tbUser(0)        _USRid = userid        _USRPassword = password        _USREmail = trUser.USREmail        _USRTitle = trUser.USRTitle        _USRName = trUser.USRName        _USRRole = trUser.USRRole        _USRAgreedConditions = trUser.USRAgreedConditions
However, there is a problem.  The database field USRAgreedConditions is a Datetime field that can be null.  The new version works perfectly when it is NOT null, but throws an exception: -
System.Data.StrongTypingException was unhandled by user code  Message="The value for column 'USRAgreedConditions' in table 'NZGDB_User' is DBNull."  Source="App_Code.wt2vzoc1"  ....
There is no point in writing: -        If Not IsDBNull(trUser.USRAgreedConditions) Then            _USRAgreedConditions = trUser.USRAgreedConditions        End Ifbecause the exception occurs within the automatically-created code in the data access layer.  I tried changing the Nullvalue property of the field USRAgreedConditions in the table adaptor, but the only valid option is (Throw Exception) unless the field is a String.  Of course USRAgreedConditions is a Datetime field, so I can't change the property.
It seems that my only options are: -1.   To stick with the old query-building code.   But this doesn't give me the advantages of a proper 3-tier architecture2.   To change the generated code in wt2vzoc.  This MUST be a bad idea - surely I should leave this code untouched.  Besides, what if the table adaptor has to be regenerated when I change the table design?3.   Code a Try block within the business layer: -    Try         _USRAgreedConditions = trUser.USRAgreedConditions    Catch ex As Exception         _USRAgreedConditions = Nothing    End Try
This seems to work OK, but seems less elegant than the original code in the old version: -       If IsDBNull(reader("USRAgreedConditions")) = False Then            _USRAgreedConditions = reader("USRAgreedConditions")       End IfIs there a better way?

View 4 Replies View Related

RS2005: Export To Excel Error: Destination Array Was Not Long Enough. Check DestIndex And Length, And The Array's Lower Bounds.

Jan 25, 2007

All,

I am using Reporting Services 2005. One of my reports is getting the following error when I try to export to Excel. It will export to .CSV though.

"Destination array was not long enough. Check destIndex and length, and the array's lower bounds."

Any suggestions would be greatly appreciated. Please copy me at machelle.a.chandler@intel.com.

Machelle

View 10 Replies View Related

How Would I Send A String Array As A Integer Array?

Jun 25, 2007

I have a stored procedure that has a paramter that accepts a string of values. At the user interface, I use a StringBuilder to concatenate the values (2,4,34,35,etc.) I would send these value to the stored procedure. The problem is that the stored procedure doesn't allow it to be query with the parameter because the Fieldname, "Officer_UID" is an integer data type, which can't be query against parameter string type.
What would I need to do to convert it to an Integer array?
@OfficerIDs as varchar(200) 
Select Officer_UID From Officers Where Officer_UID in (@OfficerIDs)
 Thanks

View 5 Replies View Related

Subreports: Parameter Value Dropdown Shows Sum And Count Fields But Not The Actual Data Fields.

Jan 28, 2008


I have just started using SQL Server reporting services and am stuck with creating subreports.

I have a added a sub report to the main report. When I right click on the sub report, go to properties -> Parameters, and click on the dropdown for Parameter Value, I see all Sum and Count fields but not the data fields.

For example, In the dropdownlist for the Parameter value, I see Sum(Fields!TASK_ID.Value, "AppTest"), Count(Fields!TASK_NAME.Value, "CammpTest") but not Fields!TASK_NAME.Value, Fields!TASK_ID.Value which are the fields retrieved from the dataset assigned to the subreport.

When I manually change the parameter value to Fields!TASK_ID.Value, and try to preview the report, I get Error: Subreport could not be shown. I have no idea what the underlying issue is but am guessing that it's because the field - Fields!TASK_ID.Value is not in the dropdown but am trying to link the main report and sub report with this field.

Am I missing something here? Any help is appreciated.

Thanks,
Sirisha

View 3 Replies View Related

Creating A Table In SQL Server With Fields From Other Tables And Some Fields User Defined

Feb 20, 2008

How can I create a Table whose one field will be 'tableid INT IDENTITY(1,1)' and other fields will be the fields from the table "ashu".
can this be possible in SQL Server without explicitly writing the"ashu" table's fields name.

View 8 Replies View Related

Public Overridable ReadOnly Default Property Fields() As ADODB.Fields

Jan 26, 2008

sir

I have got this error message to establish connction with recordset vb .net, Can you please rectify this

Too many arguments to 'Public Overridable ReadOnly Default Property Fields() As ADODB.Fields'

my code like this


rs = New ADODB.Recordset

rs.Open("Select * from UserLogin where userid='" & txtUserName.Text & "'", gstrDB, DB.CursorTypeEnum.adOpenStatic)


If txtUserName.Text = rs.Fields.Append(userid) Then


MsgBox("OK", MsgBoxStyle.OKOnly, "Confirmation")

End If


thanks

View 1 Replies View Related

Update Fields With Searched First Date Record Fields

Jul 23, 2005

Hello !I'm trying to update one table field with another table searched firstdate record.getting some problem.If anyone have experience similar thing or have any idea about it,please guide.Sample case is given below.Thanks in adv.T.S.Negi--Sample caseDROP TABLE TEST1DROP TABLE TEST2CREATE TABLE TEST1(CUST_CD VARCHAR(10),BOOKING_DATE DATETIME,BOOKPHONE_NO VARCHAR(10))CREATE TABLE TEST2(CUST_CD VARCHAR(10),ENTRY_DATE DATETIME,FIRSTPHONE_NO VARCHAR(10))DELETE FROM TEST1INSERT INTO TEST1 VALUES('C1',GETDATE()+5,'11111111')INSERT INTO TEST1 VALUES('C1',GETDATE()+10,'22222222')INSERT INTO TEST1 VALUES('C1',GETDATE()+15,'44444444')INSERT INTO TEST1 VALUES('C1',GETDATE()+16,'33333333')DELETE FROM TEST2INSERT INTO TEST2 VALUES('C1',GETDATE(),'')INSERT INTO TEST2 VALUES('C1',GETDATE()+2,'')INSERT INTO TEST2 VALUES('C1',GETDATE()+11,'')INSERT INTO TEST2 VALUES('C1',GETDATE()+12,'')--SELECT * FROM TEST1--SELECT * FROM TEST2/*Sample dataTEST1CUST_CD BOOKING_DATE BOOKPHONE_NOC12005-04-08 21:46:47.78011111111C12005-04-13 21:46:47.78022222222C12005-04-18 21:46:47.78044444444C12005-04-19 21:46:47.78033333333TEST2CUST_CD ENTRY_DATE FIRSTPHONE_NOC12005-04-03 21:46:47.800C12005-04-05 21:46:47.800C12005-04-14 21:46:47.800C12005-04-15 21:46:47.800DESIRED RESULTCUST_CD ENTRY_DATE FIRSTPHONE_NOC12005-04-03 21:46:47.80011111111C12005-04-05 21:46:47.80011111111C12005-04-14 21:46:47.80044444444C12005-04-15 21:46:47.80044444444*/

View 3 Replies View Related

Transact SQL :: Get One Row From Multiple Based On Fields And Also Get Sum Of Decimal Fields?

Jul 2, 2015

I am using MS SQL 2012.  I have a table that contains all the data that I need, but I need to summarize the data and also add up decimal fields while at it.  Then I need a total of those added decimal fields. My data is like this:

I have Providers, a unique ID that Providers will have multiples of, and then decimal fields. Here are my fields:

ID, provider_name, uniq_id, total_spent, total_earned

Here is sample data:

1, Harbor, A07B8, 500.00, 1200.00
2, Harbor, A07B8, 400.00, 800.00
3, Harbor, B01C8, 600.00, 700.00
4, Harbor, B01C8, 300.00, 1100,00
5, LifeLine, L01D8, 700.00, 1300.00
6, LifeLine, L01D8, 200.00, 800.00

I need the results to be just 3 lines:

Harbor, A07B8, 900.00, 2000.00
Harbor, B01C8, 900.00, 1800.00
LifeLine, L01D8, 900.00, 2100.00

But then I would need the totals for the Provider, so:

Harbor, 1800.00, 3800.00

View 3 Replies View Related

Enable Error Handling When Writing Custom Source Component /custom Error Handling Component.

Apr 21, 2006

1) We are writing a custome Source component for Oracle with OCI calls, Could some one please let me know how to Enable Error Handling for the Same,

2) Is it possible to write Custome Error Handeling Component for SSIS? if yes could you please help me on how to write it.

Thanks in advance.

View 1 Replies View Related

Search Multipe Fields, Compounding Fields, Like, Contains...?

Jul 20, 2005

I would like to search a table for a phrase, or for a partial phrase,eg on table product - for name or description, or name + descprition.How does one say select * from product where name + description like%phrase%or contains phraseCurrently I can get where name, or where descriotion like %phrase%,eg, where name like krups, or where description like coffee makerBut if I search for where name like %krups coffee maker% i get noresults. krups is in the name field, coffee maker is in thedescription field.Thanks,-M

View 1 Replies View Related

Update Fields With Data From Other Fields In Same Row

Jun 30, 2000

Pardon me if this question is too elementary. I am trying to create a trigger that will cause certain datafields to be updated with values from other data fields in the same row when a certain column, created specifically to fire the trigger, is updated. The purpose of this is to reduce data entry by field personnel.I think I have the create trigger statement correct, but I'm a little confused on the update statement.

In a nutshell, how can I write something like:
UPDATE "TABLENAME"
SET DATAFIELD1 = DATAFIELD2
WHERE RECORDNUMBER = (THE SAME RECORD NUMBER)

I do know that I have to ensure that sp_dboption Recursive Triggers value is set to false, thanks.

View 2 Replies View Related

Using LIKE To Find Any Of Fields In One Table In Fields Of Another

Jul 31, 2013

I have a list of items in one table and a field (pageName) in another table that may contain one of the aforementioned items somewhere within that field. There is no fixed position within the field where the itemNo may be so I can't just use SUBSTRING(pageName,2,5) in(select itemNo from tblItem).

Logically, it's like I need to combine IN and LIKE: select pageName where pageName LIKE IN %select itemNo from tblitemNo%..LIKE can only handle one comparison string.

View 5 Replies View Related

Array

Jul 17, 2007

how can i send array from asp.net to sql?

View 3 Replies View Related

Drillthrough In Calculated Fields Enable When Drillthrough Option Is Disable In Original Fields, Is This A BUG?

Jan 21, 2008

Hi people
My users are having troubles with link to default drillthrough report when reports are exported to excel (they REALLY don't like this behavior ), so I decided set all of them disabled in report model, this work fine, but calculated field in reports has this drillthrough link.


Let me show you the situation. Entity Product has an UnitaryCost field, I set the EnableDrillthrough Property in False so when I export a report with this field, no link is shown.

But if I create in the report a calculated field Round(UnitaryCost) this field has a Drillthrough Link

Is this the standard and expected behavior? or its simply a BUG?

Have I done something wrong in my model? and in this case, How I can correct this?

regards.
Julio Diaz.

View 1 Replies View Related

Get Array Value From A Loop?

Jun 19, 2006

Hi, I am trying to do a loop while a list of array is assigned ('CHP,CNH,COW') ... I am using comma seperator to get each list value ... but, it donest really do what I am trying to do ... pls help!!! How do I loop through each value and do the rest ...??
=====================================
DECLARE @ABBR AS NVARCHAR(50)SET @ABBR = 'CHP,CNH,COW'
DECLARE @SEP AS NVARCHAR(5)SET @SEP = ','
 WHILE  patindex('%,' + @ABBR + ',%',  @ABBR ) > 0    BEGIN
   -- do the rest
END

View 1 Replies View Related

SQL Query In A VB.net Array

Jan 31, 2007

I want to do a query on an SQL Server 2005 db and have the results returned into aarray or collection in vb.net... how do I do this? I know the basicconnection and stuff.. just not how to get the result to an array thanks!

View 1 Replies View Related

Array Problem

Apr 4, 2007

Hi All,
I have this code below:Dim a As Integer = 0        While a <= myArray.Length()            Conn.Open()            Dim UpdateCmd As New SqlClient.SqlCommand("Update email_addr SET category = 'Deleted' where HP = @hp", Conn)            UpdateCmd.Parameters.Add("@hp", SqlDbType.VarChar, 50).Value = myArray(a)            UpdateCmd.ExecuteNonQuery()            a = a + 1            Conn.Close()        End While
BUt, When I run it, I receive error "Prepared statement '(@hp varchar(50))Update email_addr SET category = 'Deleted' wher' expects parameter @hp, which was not supplied.  "
DOes anyone have the solution???
Thanks....
 

View 1 Replies View Related

Array In WHERE Clause

Aug 28, 2007

 Hello, how can I use an array in a WHERE clause? If I had an array saystring[] NamesArray = new string[] {"Tom", "***", "Harry"} How would I do this:string myquery = "SELET name, city, country FROM myTable WHERE name in NamesArray" Thanks in advance,Louis 

View 3 Replies View Related

DataRow Array

Jan 16, 2008

Hi,
 i m pretty new to this forum and c#.net 
i m doin a project in c#.net
I have four values in my datarow array
for example
DataRow[] cmb;
cmb=dsResult.Tables[0].Select("Controls Like 'cmb%'");// Here i m getting four Rows
 
for(i=0;i<cmb.Length;i++)
{
cmb[i]=Session["cmb'+i].ToString().Trim()//Here i m getting error;Cannot implicitly convert type 'string' to 'System.Data.DataRow'
}
 
 How to assign my session values to them.
I want to assign my value stored in the session variable to that array.Is there any way i can do it.Can i convert datarow array to string array! Please can any one help
me.
 

View 6 Replies View Related

Parameterized Or Array With This SQL?

Jun 2, 2008

I have two CheckBoxList controls. One CheckBoxList is a group of area codes as they apply to our customers, and the second CheckBoxList is a group of categories of those customers. The code below works fine with either CheckBoxList as a standalone (this code applies to the Area Codes selection), but what I need is the VB code to combine the choices a user makes in both CheckBoxLists. Is this where parameterized SQL comes into play? Or can I/should I use an array statement to combine both CheckBoxList choices? Sometimes a user will select nothing in one CBL and a few choices in the other, or vice versa, or a handful of choices in both CBLs, so that they might want only customers in, say two area codes and then only the selected categories of those area codes.  Need help on this one, thanks...Protected Sub btn_CustomerSearchCombine_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_CustomerSearchCombine.Click        Dim ACSelections As Boolean = False        Dim ACItem As ListItem        For Each ACItem In cbl_CustomerSearchAREA.Items             If ACItem.Selected Then                ACSelections = True            End If        Next        If ACSelections = True Then            Dim ACSqlString As String            ACSqlString = "SELECT Customers.CustomerID, Customers.CustomerName, Customers.CategoryID, Customers.EstHours, Customers.Locality, Categories.Category FROM Customers INNER JOIN Categories ON Customers.CategoryID = Categories.CategoryID WHERE "            For Each ACItem In cbl_CustomerSearchAREA.Items                If ACItem.Selected Then                    ACSqlString &= "Customers.AreaCodeID = '" & ACItem.Value & "' OR "                End If            Next            ACSqlString = Left(ACSqlString, Len(ACSqlString) - 4)            ACSqlString &= "ORDER By Customers.CustomerName"            sql_CustomerSearchGrid.SelectCommand = ACSqlString        End IfEnd Sub 

View 7 Replies View Related

Result Set Into Array

Aug 22, 2004

Hi All,

How can I read a query result set (which are of type VARCHAR) into an array? i.e the result set comprises of just one column and 5 rows and i want to save these into an array to easily extract each row whenever i want to. Hope I have conveyed my idea clearly.

Gayathri

View 1 Replies View Related

SqlCommand Array Help

Feb 19, 2006

I want to do something like the following but I get an error: Object reference not set to an instance of an object.       SqlConnection sqlConnection = new SqlConnection("server=xxxxx");        SqlCommand [] cmd = new SqlCommand[3];        Object returnValue;          cmd[0].CommandText = "DO QUERY";          cmd[1].CommandText = "DO QUERY";          cmd[2].CommandText = "DO QUERY";          cmd[3].CommandText = "DO QUERY";        }        sqlConnection.Open();int i = 0;while(i<4){       cmd[i].CommandType = CommandType.Text;        cmd[i].Connection = sqlConnection;        cmd[i].ExecuteNonQuery();        returnValue[i] = cmd[i].ExecuteScalar();i++}        sqlConnection.Close();How should I do the followingThanks

View 9 Replies View Related

Inline Sql With An Array

Sep 20, 2006

I have data which looks like below

actid labname
100 CKS
200 CKS;HDP;LAS

I need the data to be

actid labname
200 CKS
200 HDP
200 LAS

The ; is the seperator

For a reporting product I created a sp which created a temp table and then using my function below built. problem is the product won't allow me to create a temp table. With what I have below anyone have any creative ideas I could use. In-line sql, subquery views?

select enc_id,labcnt,order_name,date_due


reate FUNCTION fn_GET_ARRAY_VALUE(
@DELIMITER VARCHAR(100),
@STRING VARCHAR(1000),
@ARRAY_POSITION INT)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @CURRENT_POSITION INT
DECLARE @VALUE VARCHAR(8000)
SET @CURRENT_POSITION = 0

WHILE @CURRENT_POSITION<@ARRAY_POSITION
AND CHARINDEX(@DELIMITER,@STRING,0)>0
BEGIN
SET @STRING =
SUBSTRING(@STRING,
CHARINDEX(@DELIMITER, @STRING, 0)
+LEN(@DELIMITER),
LEN(@STRING)
-CHARINDEX(@DELIMITER, @STRING, 0)
+ LEN(@DELIMITER)
)
SET @CURRENT_POSITION = @CURRENT_POSITION + 1
END

IF CHARINDEX(@DELIMITER,@STRING,0)=0
SET @VALUE = @STRING
ELSE
SET @VALUE = SUBSTRING(@STRING, 0,
CHARINDEX(@DELIMITER, @STRING, 0)
)

RETURN(LTRIM(RTRIM(@VALUE)))
END

View 3 Replies View Related

Array List In DB

Feb 14, 2005

Hi,
Is it possible to have a column as array in SQL Server 2000- similar to Oracle's varray. If yes, how?
rgds,

Kishore

View 14 Replies View Related

Array In SQL Server

Jan 27, 2004

How would one implement an array in SQL Server ?

Specically, i'm parsing a field into the array, and doing operations on these elements.

Thanks.

View 4 Replies View Related

Array In A STOC??

Feb 3, 2004

Hi all,

My Issue is the next thing:
I have a table filled with contracts
I have Stoc that checks if contract has expired
If I start the Stoc I must give it the contractnumber with it like:
SP_expired 8

This works fine but now I want that the Stoc checks all the contracts by just starting the Stoc.

I don't really know how to do this, I have thinking about using an array.
But don't have an idea where to start....

Thnx in advance

View 8 Replies View Related

Dynamic Array

Jan 3, 2007

Please excuse me if this is the wrong forum. I hope your combined genius will be able to point me in the right direction.

I have an ASP page that accepts any SQL query. I want to create a table based on the result set so the number of columns can grow/shrink. But I don't know how. Can anyone help me?

My ASP Code shows how I create a table with only 8 fields.

<%
Dim objConn
dim SQLstmt
Dim objRS
Dim SQLqry
Dim UID
Dim RecordArray
Dim I

UID = right(Request.ServerVariables("AUTH_USER"),8)
SQLqry = Request.Form("qry")

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="Trusted_Connection=yes;driver=SQL Server;server=Server;database=db;"
objConn.Open


If SQLqry = "" then
Response.Write "Please Enter a SQL Query"
Else

Set objRS = objConn.Execute(SQLqry)
Response.Write "<H5 align = ""center"">" & sqlqry & "</H5>"

Response.Write "<Table align = ""center"" border = ""1"">"
For I = 0 To objRS.Fields.Count - 1
Response.Write "<TD><B>" & objRS(I).Name & "</B></TD>"
Next


Do while not objRS.EOF
RecordArray = objRS.GetRows(30)

For I = 0 To UBound(RecordArray,2)
Response.Write "<TR>"
Response.Write "<TD>" & RecordArray(0,I) & "</TD>"
Response.Write "<TD>" & RecordArray(1,I) & "</TD>"
Response.Write "<TD>" & RecordArray(2,I) & "</TD>"
Response.Write "<TD>" & RecordArray(3,I) & "</TD>"
Response.Write "<TD>" & RecordArray(4,I) & "</TD>"
Response.Write "<TD>" & RecordArray(5,I) & "</TD>"
Response.Write "<TD>" & RecordArray(6,I) & "</TD>"
Response.Write "<TD>" & RecordArray(7,I) & "</TD>"
Response.Write "</TR>"
Next
Loop
Response.Write "</TABLE>"
objRS.close
objConn.close
set objRS=nothing
set objConn=nothing

End if
%>

View 3 Replies View Related

Array As Parameter

Jan 28, 2008

hi guys im having some problems with arrays as parameter
what i want to do is pass a array of comma separated values i.e 12,24,36 and use the in(@parameter) but it doesnt work

i've found some solutions, like
ALTER PROCEDURE [dbo].[GetLawyers] ( @LawyerTypeIDs VARCHAR(100)
AS

DECLARE @SQL VARCHAR(2000)

SET @SQL = 'SELECT * FROM [dbo].[TB_VALOR_BANCOS]
WHERE [PARCELAS] IN (' + @LawyerTypeIDs + ')'
EXECUTE (@SQL)

but in my case doesnt work.

here is a part of my code
SELECT * FROM (
SELECT *, ROW_NUMBER()
OVER (PARTITION BY cod_banco ORDER BY coeficiente asc) AS RecID FROM tb_valor_bancos
where
(1 = CASE WHEN @TABELA IS NULL THEN 1
ELSE CASE WHEN TABELA = @TABELA THEN 1
ELSE 0
END
END
)
AND (1 = CASE WHEN @PARCELAS IS NULL THEN 1
ELSE CASE WHEN PARCELAS in(@PARCELAS) THEN 1
ELSE 0
END
END
)
...

i know there is a way to pass the array into a table but it doesnt work too

thanks

View 4 Replies View Related

Split Array

Feb 21, 2008

hi,

how can i split text separated by semicolumn in different cells:

text1;text2;text3;
into
1 - text1
2 - text2
3 - text3

thank you

View 4 Replies View Related

How To Identify An Array

Nov 20, 2006

I have seen several examples explaining the fact that a tablecontaining a field for each day of the week is for the most part anarray. An specific example is where data representing worked hours isstored in a table.CREATE TABLE [hoursWorked] ([id] [int] NOT NULL ,[location_id] [tinyint] NOT NULL,[sunday] [int] NULL ,[monday] [int] NULL ,[tuesday] [int] NULL ,[wednesday] [int] NULL ,[thursday] [int] NULL ,[friday] [int] NULL ,[saturday] [int] NULL)I had to work with a table with a similar structure about 7 years agoand I remember that writing code against the table was pretty close toHell on earth.I am now looking at a table that is similar in nature - but different.CREATE TABLE [blah] ([concat_1_id] [int] NOT NULL ,[concat_2_id] [int] NOT NULL ,[code_1] [varchar] (30) NOT NULL ,[code_2] [varchar] (20) NULL ,[code_3] [varchar] (20) NULL ,[some_flg] [char] (1) NOT NULL) ON [PRIMARY]The value for code_2 and code_3 will be dependently null and they willrepresent similar data in both records (i.e. the value "abc" can existin both fields) . For example if code_2 contains data then code_3 willprobably not contain data.I do not think that this is an array. But with so many rows wherecode_2 and code_3 will be NULL something just does not feel right.I will appreciate your input.

View 1 Replies View Related

Array In TSQL

Sep 19, 2007

Hi all,

I have data like this :

POHDR;JAKARTA;St.1DTL;1. ;00248337;8996006855701 ;083;041;002; 7,812.50; 312,500.00; 284,091.00; 8,875.00
first row is the PO header and the second is the detail. This data was collected using Export Import Wizard from flatfile and put it in one column. I want to split the header and the detail into different table and map each column separated by ; to a proper field. For this work I should check every column separated by ; with CHARINDEX function but I have to write the TSQL as much as the count of ;. It would be better if we can use array to simplify the code.

Can we use array in Transact SQL ? since I have no clue referring to SQLBOL. Thanks in advance.

Best regards,

Hery

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved