Array List In DB
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 Complete Forum Thread with Replies
Related Forum Messages:
Sort Array List
I've got the following variables: CurFile string, FileCount int, FileList Object I've got a Foreach Loop Container that loops thru a list of files in a directory. Inside the Foreach Loop Container, I have a Script Task. In the script, I'd like to assign FileList(FileCount) = Dts.Variables("CurFile").Value Thus, For each file in the directory, I want to put all those files into the FileList Array Object. Then I want to sort the Array. How would I be able to do this? I'd like the easiest way without writing to a database table. Thanks in advanced. Dave
View Replies !
Array List In WebService
Hi, How i can get the FileNames that are stored in Web Server. Dim strFiles As String = Server.MapPath("~/UploadedFiles/") Dim dirinfo As New DirectoryInfo(strFiles) dirinfo.GetFiles("*.doc") The above Method Iam writing in Web Service. These files will display in a DataGrid in Windows Application.
View Replies !
Passing A List/array To An SQL Server Stored Procedure 2005
Hi, I m using sql 2005 as a back end in my application... I am useing Store procedure..for my data in grid.. ALTER PROCEDURE [dbo].[ProductZoneSearct] ( @Productid char(8),@Proname char(8),@radius int,@mode varchar(5) = 'M',@Zone nvarchar(1000),) ASSET NOCOUNT ON;Create Table #Product (ProductID int, TimeEntered datetime, DateAvailable datetime, Productname varchar(80), City varchar(50), State char(4),Miles decimal, Payment varchar(40),UserID int, Phone varchar(15)) Insert #Product Select ProductID , TimeEntered, DateAvailable, Productname ,City,State,miles,Payment ,Miles, UserID, Daily, PhoneFrom [tblproduct] Where city IN (@Zone) Select ProductID TimeEntered, DateAvailable, Productname City,State,miles,Payment ,Miles, U.Phone As phoneNumber, Company, , L.Phone As cmpPhone From #Product As L Left Join (Select UserID, Company, Phone, From [User]) As U On U.UserID = L.UserID Order By DateAvailable if i pass value in "where city in (@Zone)" and @Zone ='CA','AD','MH' then it can not get any result..but if write where city in ('CA','AD','MH') then it give me perfact result.. I tried to below syntax also but in no any user Where city IN ('+@Zone+') In short if i pass value through varibale (@Zone) then i cant get result...but if i put direct value in query then only getting result..can anybody tell me what is problem ? Please Hel[p me !!! Thank you !!!
View Replies !
How Would I Send A String Array As A Integer Array?
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 Replies !
Array Of Array - IRR Function
Hi, I am using the IRR function in a report. I have created the following code so it creates an array: Public GroupIRRArray(-1) As Double Public Function addToIRRArray(ByVal BMV As Decimal, ByVal BAB As Decimal, ByVal EMV As Decimal, ByVal EAB As Decimal, ByVal CFB As Decimal) Dim g As Integer g = uBound(GroupIRRArray) + 1 ReDim Preserve GroupIRRArray(g) if g=0 then GroupIRRArray(g) = (CFB+EAB-BAB+BMV)*-1 else if g=1 then GroupIRRArray(g) = (BAB-CFB-EAB+EMV) else GroupIRRArray(g-1)= GroupIRRArray(g-1)-(BMV) GroupIRRArray(g) = (BAB-CFB-EAB+EMV) end if End Function It works fine but now I want to create multiple groups within my report. How can I change the code so it loops on another parameter? What I had in mind was to create an initial array with the parameter value that I want to use for grouping and a dynamic array based on the name of each group. So I would end up with one array containing the group name plus x number of arrays with the raw data. Alternatively, is there a way to use the IRR function without creating a custom code? Like a conversion parameter that would make my floating field a one dimensional array? Thanks, Jam
View Replies !
Report Designer: Need To List Fields From Multiple Result Rows As Comma Seperated List (like A JOIN On Parameters)
I know I can do a JOIN(parameter, "some seperator") and it will build me a list/string of all the values in the multiselect parameter. However, I want to do the same thing with all the occurances of a field in my result set (each row being an occurance). For example say I have a form that is being printed which will pull in all the medications a patient is currently listed as having perscriptions for. I want to return all those values (say 8) and display them on a single line (or wrap onto additional lines as needed). Something like: List of current perscriptions: Allegra, Allegra-D, Clariton, Nasalcort, Sudafed, Zantac How can I accomplish this? I was playing with the list box, but that only lets me repeat on a new line, I couldn't find any way to get it to repeate side by side (repeat left to right instead of top to bottom). I played with the orientation options, but that really just lets me adjust how multiple columns are displayed as best I can tell. Could a custom function of some sort be written to take all the values and spit them out one by one into a comma seperated string?
View Replies !
Insert Value List Doest Not Match Column List
HI... I need to do a simple task but it's difficult to a newbie on ssis.. i have two tables... first one has an identity column and the second has fk to the first... to each dataset row i need to do an insert on the first table, get the @@Identity and insert it on the second table !! i'm trying to use ole db command but it's not working...it's showing the error "Insert Value list doest not match column list" here is the script INSERT INTO Address( CepID, Street, Number, Location, Complement, Reference)Values ( ?, ?, ?, ?, ?, ? ) INSERT INTO CustomerAddress( AddressID, CustomerID, AddressTypeID, TypeDescription) VALUES( @@Identity, ?, ?, ? ) what's the problem ??
View Replies !
Insert Only New Items From A List But Get ID's For New And Existing In The List.
Hi, I have a a table that holds a list of words, I am trying to add to the list, however I only want to add new words. But I wish to return from my proc the list of words with ID, whether it is new or old. Here's a script. the creates the table,indexes, function and the storeproc. call the proc like procStoreAndUpdateTokenList 'word1,word2,word3' My table is now 500000 rows and growing and I am inserting on average 300 words, some new some old. performance is a not that great so I'm thinking that my code can be improved. SQL Express 2005 SP2 Windows Server 2003 1GB Ram....(I know, I know) TIA Code Snippet GO CREATE TABLE [dbo].[Tokens]( [TokenID] [int] IDENTITY(1,1) NOT NULL, [Token] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, CONSTRAINT [PK_Tokens] PRIMARY KEY CLUSTERED ( [TokenID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO CREATE UNIQUE NONCLUSTERED INDEX [IX_Tokens] ON [dbo].[Tokens] ( [Token] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = ON, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO CREATE FUNCTION [dbo].[SplitTokenList] ( @TokenList varchar(max) ) RETURNS @ParsedList table ( Token varchar(255) ) AS BEGIN DECLARE @Token varchar(50), @Pos int SET @TokenList = LTRIM(RTRIM(@TokenList ))+ ',' SET @Pos = CHARINDEX(',', @TokenList , 1) IF REPLACE(@TokenList , ',', '') <> '' BEGIN WHILE @Pos > 0 BEGIN SET @Token = LTRIM(RTRIM(LEFT(@TokenList, @Pos - 1))) IF @Token <> '' BEGIN INSERT INTO @ParsedList (Token) VALUES (@Token) --Use Appropriate conversion END SET @TokenList = RIGHT(@TokenList, LEN(@TokenList) - @Pos) SET @Pos = CHARINDEX(',', @TokenList, 1) END END RETURN END GO CREATE PROCEDURE [dbo].[procStoreAndUpdateTokenList] @TokenList varchar(max) AS BEGIN SET NOCOUNT ON; create table #Tokens (TokenID int default 0, Token varchar(50)) create clustered index Tind on #T (Token) DECLARE @NewTokens table ( TokenID int default 0, Token varchar(50) ) --Split ID's into a table INSERT INTO #Tokens(Token) SELECT Token FROM SplitTokenList(@TokenList) BEGIN TRY BEGIN TRANSACTION --get ID's for any existing tokens UPDATE #Tokens SET TokenID = ISNULL( t.TokenID ,0) FROM #Tokens tl INNER JOIN Tokens t ON tl.Token = t.Token INSERT INTO Tokens(Token) OUTPUT INSERTED.TokenID, INSERTED.Token INTO @NewTokens SELECT DISTINCT Token FROM #Tokens WHERE TokenID = 0 return the list with id for new and old SELECT TokenID, Token FROM #Tokens WHERE TokenID <> 0 UNION SELECT TokenID, Token FROM @Tokens COMMIT TRANSACTION END TRY BEGIN CATCH DECLARE @er nvarchar(max) SET @er = ERROR_MESSAGE(); RAISERROR(@er, 14,1); ROLLBACK TRAN END CATCH; END GO
View Replies !
Select List Contains More Items Than Insert List
I have a select list of fields that I need to select to get the results I need, however, I would like to insert only a chosen few of these fields into a table. I am getting the error, "The select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns." How can I do this? Insert Query: insert into tsi_payments (PPID, PTICKETNUM, PLINENUM, PAMOUNT, PPATPAY, PDEPOSITDATE, PENTRYDATE, PHCPCCODE) SELECT DISTINCT tri_IDENT.IDA AS PPID, tri_Ldg_Tran.CLM_ID AS PTicketNum, tri_ClaimChg.Line_No AS PLineNum, tri_Ldg_Tran.Tran_Amount AS PAmount, CASE WHEN tln_PaymentTypeMappings.PTMMarsPaymentTypeCode = 'PATPMT' THEN tri_ldg_tran.tran_amount * tln_PaymentTypeMappings.PTMMultiplier ELSE 0 END AS PPatPay, tri_Ldg_Tran.Create_Date AS PDepositDate, tri_Ldg_Tran.Tran_Date AS PEntryDate, tri_ClaimChg.Hsp_Code AS PHCPCCode, tri_Ldg_Tran.Adj_Type, tri_Ldg_Tran.PRS_ID, tri_Ldg_Tran.Create_Time, tri_Ldg_Tran.Adj_Group, tri_Ldg_Tran.Payer_ID, tri_Ldg_Tran.TRN_ID, tri_ClaimChg.Primary_Claim, tri_IDENT.Version FROM [AO2AO2].MARS_SYS.DBO.tln_PaymentTypeMappings tln_PaymentTypeMappings RIGHT OUTER JOIN qs_new_pmt_type ON tln_PaymentTypeMappings.PTMClientPaymentDesc = qs_new_pmt_type.New_Pmt_Type RIGHT OUTER JOIN tri_Ldg_Tran RIGHT OUTER JOIN tri_IDENT LEFT OUTER JOIN tri_ClaimChg ON tri_IDENT.Pat_Id1 = tri_ClaimChg.Pat_ID1 ON tri_Ldg_Tran.PRS_ID = tri_ClaimChg.PRS_ID AND tri_Ldg_Tran.Chg_TRN_ID = tri_ClaimChg.Chg_TRN_ID AND tri_Ldg_Tran.Pat_ID1 = tri_IDENT.Pat_Id1 LEFT OUTER JOIN tri_Payer ON tri_Ldg_Tran.Payer_ID = tri_Payer.Payer_ID ON qs_new_pmt_type.Pay_Type = tri_Ldg_Tran.Pay_Type AND qs_new_pmt_type.Tran_Type = tri_Ldg_Tran.Tran_Type WHERE (tln_PaymentTypeMappings.PTMMarsPaymentTypeCode <> N'Chg') AND (tln_PaymentTypeMappings.PTMClientCode = 'SR') AND (tri_ClaimChg.Primary_Claim = 1) AND (tri_IDENT.Version = 0)
View Replies !
ERROR: A Variable May Only Be Added Once To Either The Read Lock List Or The Write Lock List.
Hi, I have set of 2 DTS packages, one of which calls the other by forming a command-line (dtexec) using a Execute Process task. From the parent package-> Execute Process Task-> dtsexec /F etc... /<pkg variable> = "servername" Each of the parent and the called package have a variable: "User::DWServerSQLInstance" which is mapped to the SQL server connection manager server name property using an expression. The outer package has the above variable and so does the inner called package (which gets assigned through the command line from the outerpackage call to inner) I "sometimes" get the following error: OnError,I4,TESTDOMAdministrator,ACDWAggregation,{A1F8E43F-15F1-4685-8C18-6866AB31E62B},{77B2F3C7-6756-46EB-8C01-D880598FB4B3},5/22/2006 5:10:28 PM,5/22/2006 5:10:28 PM,-1073659822,0x,The variable "User::DWServerSQLInstance" is already on the read list. A variable may only be added once to either the read lock list or the write lock list. Help would be appreciated! I have seen other posts on this but, not able to relate the solution to my scenario.
View Replies !
A Variable May Only Be Added Once To Either The Read Lock List Or The Write Lock List
Hi All, I have seen a few other people have this error. Package works fine when run from BIDS, DTExec, dtexecui. When I schedule it, It get these random errors. (See below) The main culprit is a variable called "RecordsetFileDIR" which is set using an expression. (@[User::_ROOT] + "RecordSets\") A number of other variables use this as part of their expression and as they all fail, pretty much everything dies. I have installed SP1 (Not Beta) on server. Package uses config files to set the value of _ROOT. The error does not always seem to be with this particular variable though. Always a variable that uses an expression but errors are random. Also, It will run 3 out of 10 times without a problem. I am the only person on the server at the time. Any ideas? Cheers, Crispin Error log: OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073659822,0x,The variable "User::RecordsetFileDIR" is already on the read list. A variable may only be added once to either the read lock list or the write lock list. OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073639420,0x,The expression for variable "rsHeaderFile" failed evaluation. There was an error in the expression. OnError,,,DF_Header_Header,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA. OnError,,,Move All Data,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA. OnError,,,Load Open Batches and Process Files,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA. OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA. OnError,,,DF_Header_Header,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property. OnError,,,Move All Data,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property. OnError,,,Load Open Batches and Process Files,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property. OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property. OnError,,,DF_Header_Header,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN". OnError,,,Move All Data,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN". OnError,,,Load Open Batches and Process Files,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN". OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN".
View Replies !
Array
I messed up my question so badly a few posts ago, that I'm going to lay out the problem carefully as follows: On a spreadsheet: --there are a few names down column A, one name per row (e.g., r3c1Mary, r4c1Scott, r5c1Jane, r6c1Ann, r7c1Cathy, r8c1Jim) --there are a bunch of columnar animals heading up row 1 (e.g., r1c2cat, r1c4dog, r1c6horse, r1c8bird, r1c10snake, r1c12elephant, r1c14goat, r1c16giraffe, r1c18ox, r1c20rat, r1c22monkey, r1c24pig) --(might be addressed in a later post to this or another thread): on row 2, there is a Budget field and a Cost field for each animal (e.g., r2c2Bud, r2c3Cost, r2c4Bud, r2c5Cost, r2c6Bud, r2c7Cost, r2c8Bud, r2c9Cost, r2c10Bud, r2c11Cost, r2c12Bud, r2c13Cost, r2c14Bud, r2c15Cost, r2c16Bud, r2c17Cost, r2c18Bud, r2c19Cost, r2c20Bud, r2c21Cost, r2c22Bud, r2c23Cost, r2c24Bud, r2c25Cost) But for now, just the people names down the left side, and the animals across the top would suffice to pose my question. The question is this: the number of animal types gets added to, or subtracted from, across the top of the page every month. On July, there might be 12 animal kinds listed; but on August, there might be 19--or there might be 11. (The number of people involved change as well.) As a user, I don't know how many and of what kind of animals (aka fields) will be on the page on any given month. The underlying query to the table doesn't know whether a Giraffe is going to be a category, among others at the top of the sheet, from one month to the next. If a garden variety query was written, it would hard code: SELECT r1c2cat, r1c4dog, r1c6horse, r1c8bird, r1c10snake, r1c12elephant, r1c14goat, r1c16giraffe, r1c18ox, r1c20rat, r1c22monkey, r1c24pig. But that rots. The query would have to be re-written for every new list of applicable animals each month. Or even more ugly, I'd have a predetermined number of variables to hold each type of animal; some would go unused while a number exceeding the variables available wouldn't make it into the query, or whatever. I could on the other hand slowly loop through a SELECT sAnimalType for each sPerson. Slowly. That's where my question comes in: Can a query be written that allocates a SELECT Array(sAnimalType)? (And if so, I hope I can extract the sequential info accordingly.) Simplified, I currently have an Access table with two columns (four if we go whole hog): Person, Animal (, Budget, Cost). (But I'm perfectly happy to leave Budget and Cost for a separate posting. Maybe that's a sub query or something.) Thanks for any assistance that you can provide.
View Replies !
Parameterized Or Array With This SQL?
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 Replies !
DataRow Array
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 Replies !
SqlCommand Array Help
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 Replies !
Array In WHERE Clause
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 Replies !
Array Problem
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 Replies !
SQL Query In A VB.net Array
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 Replies !
Get Array Value From A Loop?
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 Replies !
Result Set Into Array
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 Replies !
How To Identify An Array
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 Replies !
Array In SQL Server
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 Replies !
Array In A STOC??
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 Replies !
Array Of Recordsets
Hi, I have a form with several tabs, on each tab has a similar structure : on each tab description of a table in database (different tables on each tab). I was wondering : is there a possibility to create an array of recordsets? (in this case i could attach an index of recordset to index of tab )
View Replies !
Do Loop Or Array In SQL
How does one perform a do loop in SQL. Is there any documentation on it somewhere I can read? Also, how might SQL handle arrays? Any help would be greatly appreciated it Thank you all for you help. Rey
View Replies !
Inline Sql With An Array
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 Replies !
Array Parameter
Is there any way to make a CLR stored procedure that accepts an array style set of data? I want to make a stored procedure that accepts to parameters of type int, and then one more that is an array of name/value pairs. Is it possible to do something like this?
View Replies !
2 Dimensional Array
Hi. Does anyone know how to pass a 2 dimensional array into a stores procedure? I need to loop through it and insert it into a table. Thanks!
View Replies !
Create An Array With T-SQL
I'm using SQL Server 2005 and have have a table similar to the following: Name Week Role Bob 1 Primary Bob 2 Backup Bob 3 Primary Joe 1 Backup Joe 2 Backup Mike 1 Primary Mike 2 Backup Is there a t-SQL query that will combine the role and week into an array and return a table like: Name Role Bob Primary: 1, 3 Backup: 2 Joe Backup: 1, 2 Mike Primary: 1 Backup: 2
View Replies !
Array In TSQL
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 Replies !
Split Array
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 Replies !
Array As Parameter
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 Replies !
Dynamic Array
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 Replies !
Items In List A That Don't Appear In List B (was &"Simple Query...I Think&")
Ok, I want to write a stored procedure / query that says the following: Code: If any of the items in list 'A' also appear in list 'B' --return false If none of the items in list 'A' appear in list 'B' --return true In pseudo-SQL, I want to write a clause like this Code: IF (SELECT values FROM tableA) IN(SELECT values FROM tableB) Return False ELSE Return True Unfortunately, it seems I can't do that unless my subquery before the 'IN' statement returns only one value. Needless to say, it returns a number of values. I may have to achieve this with some kind of logical loop but I don't know how to do that. Can anyone help?
View Replies !
Need Help Building/reading C# SQL Array
I'm stuck and uinder a bit of a time crunch. I have 5 fields I want to get out of a sql database using a function that I'm writing. I figure it sounds like an array. basically I want to make an array, and fill it up with the results of a sql select, then read the array. This is what I have so far..... String TempHRAcctCode, TempJobDescription, TempHourlyRate, TempEmplID; Array TempArray; TempJobDescription = DDDept.SelectedItem.Text; (to get KeY Value) SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MYCONN"].ToString()); connection.Open(); SqlCommand command = new SqlCommand("Select HRAcctCode, HourlyRate , EmplID, ... FROM TimeMyProfile WHERE JobDescription = " + TempJobDescription + " ", connection); SqlDataReader TempDataReader = command.ExecuteReader; while TempDataReader.Read ( ... OK I GIVE UP! Thanks in advance
View Replies !
Get &> Array &> Split &> Listbox
Hi everyone, having some problems Basically, using ASP.NET 2.0 and here is my problem, Get data from table Put into array Split where there is a + remove +'s assign to listbox to give a list of everything in that table The + split the courses, so in my Order table I have A + B + C etc and I want all of the different options in a list box (note different records have different entries it isn't always a b c) I am testing my code, here is what I got Public Sub TitleChange(ByVal Sender As Object, ByVal E As EventArgs) Try Dim DBConn As SqlConnection Dim DSPageData As DataSet = New DataSet() Dim VarTxtAOE As String DBConn = New SqlConnection("Server=SD02;Initial Catalog=WhoGetsWhat;Persist Security Info=True;UID=x;Password=XXX") 'Dim DBDataAdapter As SqlDataAdapter DBDataAdapter = New SqlDataAdapter("Select AOE FROM TBL_Role WHERE Title = @ddlTitle", DBConn) DBDataAdapter.SelectCommand.Parameters.Add("@ddlTitle", SqlDbType.NVarChar) DBDataAdapter.SelectCommand.Parameters("@ddlTitle").Value = TitleDropDown.SelectedValue DBDataAdapter.Fill(DSPageData, "Courses") 'Need to find out what this rows business is about whats the number about? and am I doing it correct? 'txtAOE.Text = DSPageData.Tables("Courses").Rows(0).Item("AOE") 'txtAOE.Items.Add(New ListItem(DSPageData.Tables(0).Rows(0).Item("AOE"))) VarTxtAOE = DSPageData.Tables("Courses").Rows(0).Item("AOE") Dim VarArray() As String = VarTxtAOE.Split("+") Response.Write(VarArray()) txtAOE.DataSource = VarArray() txtAOE.DataBind() 'Response.Write(test) 'ListBox1.DataSource = test 'Response.Write(VarArray) Catch TheException As Exception lblerror.Text = "Error occurred: " & TheException.ToString() End Try End Sub My response.Write works correctly, but my list box doesn't, also I don't want to say which bit of the array like I have done using 1, I just want to display the whole array in my list box. I am not worrying about removing the +'s at the minute, just splitting my data and putting each section into a listbox Maybe I am going about this the wrong way, but I have been trying a lot of different things and its hard to find any help Thanks Chris
View Replies !
Write SQL Rows To An Array
I have an sql table called survey with rows: SurveyID, callref, question1, question2, question3, question4 etc. I want to get the information from the database with a select command like "SELECT question1, question2, question3, question4, question5, question6 WHERE SurveyID = 1" and write it to and array like this: aProfits As ArrayList = New ArrayList() aProfits.Add("question1value")aProfits.Add("question2value")aProfits.Add("question3value")aProfits.Add("question4value")aProfits.Add("question5value") Whats the best way of doing this? Andrew
View Replies !
Index Was Outside The Bounds Of The Array
Index was outside the bounds of the array When working with a SQL Server 2005 database and ASP.NET, I get this error when trying to pull a small amount of data from the database, Any help would be great, thanks a lot I work for a large company, so I have to watch the code I release.
View Replies !
Populate DB Records In Array
Using the SqlDataReader, I am retrieveing records from a SQL Server 2005 DB table. Since I am using the SqlDataReader to retrieve the records from the DB, I have to use the Read method of the SqlDataReader like this:Dim sqlReader As SqlDataReaderWhile(sqlReader.Read) Response.Write(sqlReader.GetValue(0) & "<br>") Response.Write(sqlReader.GetValue(1) & "<br>") Response.Write(sqlReader.GetValue(2) & "<br>")End WhileThe records retrieved can only be accessed inside the While loop. I want to access the records outside the While loop as well. Is there anyway by which I can do this, maybe by populating the recordset in an array variable & then using it outside the While loop?
View Replies !
Populate The Array From Database
Hi, I want to populate the array with a single column values from database(sqlserver 2000)Ex. name ageaaaa 23bbbb 43cccc 18 Now i want to populate the array with name field values. Please anyone guide me how to do this.Thanks in advanceBala
View Replies !
Populating An Array From A Sqlreader
I am trying to populate an array from a sqlreader. I am getting the error "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index". Can anyone help? I have my code below. Try sql = "...." cmd = New SqlCommand(sql, conn) SqlReader = cmd.ExecuteReader 'Get the data from SQL Server Dim Counter As Integer = 0 Do While SqlReader.Read() Counter += 1 PageArray(Counter) = SqlReader("WebPageID") Loop Catch ex As Exception lblMessage.Text = ex.Message End Try
View Replies !
Load Results Into A Array
hello peoplei'v the following problem:i got a sqldatasource from which i get results(SELECT is_stored FROM calendar WHERE week=XX)and i want to save these results to a one-dimensional arrayplease help me
View Replies !
Problem With Array Of Strings In SQL...
I am using the code given below which works fine for array of integers, can anyone help me to convert this code to use it for array of strings basically i want to store the search keywords in the array of strings and use them in the stored procedure.CREATE Function fnSplitter (@IDs Varchar(100) ) Returns @Tbl_IDs Table (ID Int) As Begin -- Append comma Set @IDs = @IDs + ',' -- Indexes to keep the position of searching Declare @Pos1 Int Declare @pos2 Int -- Start from first character Set @Pos1=1 Set @Pos2=1 While @Pos1<Len(@IDs) Begin Set @Pos1 = CharIndex(',',@IDs,@Pos1) Insert @Tbl_IDs Select Cast(Substring(@IDs,@Pos2,@Pos1-@Pos2) As Int) -- Go to next non comma character Set @Pos2=@Pos1+1 -- Search from the next charcater Set @Pos1 = @Pos1+1 End ReturnEndCREATE PROCEDURE spSelectEmployees(@IDs Varchar(100)) AS Select * From employees Where employeeid In (Select ID From fnSplitter(@IDs))Exec spSelectEmployees '1,4,5,7,9'I want replace the above Exec statement with Exec spSelectEmployees 'sap, abap, hr, .... ' in the JobPosition Column of Employees if possible, i've been trying to change it but its not working outThanks in Advance
View Replies !
UPDATE Values From An Array?
Hi there...Is it possible to write an UPDATE or INSERT query, where the new value comesfrom an array? For example:UPDATE table_a SET column_x = [@array1]WHERE column_y = [@array2];It's a query (for argument's sake called query1) in an Access database,which I'm accessing as a stored procedure through PHP, so I would run somephp code that looked possibly like this:$array1 = array("a","b","c","d");$array2 = array(1,2,3,4);$str_sql = "exec query1 $array1, $array2";my_run_query_function($str_sql);But is it possible? The information I can find about it seems to say that ithas to be an array created inside the query, but if it's a stored procedure,this isn't possible, is it?Hope someone can help...Plankmeister.
View Replies !
Array In Store Procedure
Dear all,Sometimes I happened the require that the number of input parametersof SP is not fixed, Can sql T-SQL handle the array (dynamic array)?Does anybody ever used an array name as the input parameter to callthe SP?thanks,Robert
View Replies !
|