Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Extracting values from a table into an array

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-01 : 07:59:44
Luby writes "I have a table that has a series of variables that all have the same prefix and end in consecutive numbers...eg: bp1 bp2..bp10...
I would like to know a way in which i can extract the values that are stored in these variables into an array for each row in the table.
I tried using the following code from your website:

select @separator_position = patindex('%' + @separator + '%' , @array)
select @array_value = left(@array, @separator_position - 1)


...but, this extracts the suffix from the variable name. I am interested in the content of the variables. Any help would be appreciated.

Thank You."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-01 : 08:58:03
Please post a bit more information.

"I have a table that has a series of variables" ... how does a table have variables?

<O>
Go to Top of Page

lubaina
Starting Member

1 Post

Posted - 2002-07-01 : 09:46:35
When I say variables, I mean the columns in the table.The table has columns that are named bp1,bp2,bp3......
Thanks

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-01 : 10:22:39
I'm way confused....

How bout ...... select bp1,bp2,bp3,bp4,bp5,bp6,bp7,bp8,bp9,bp10 from lubainatable ...... ?

<O>
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-07-01 : 15:09:28
What are you going to do with this array once you have it? If you just want it in, for example, and ASP page, you can use the ADO command Recordset.GetRows. If you want to continue to manipulate it in SQL Server, then an array does you no good, but perhaps a Table Variable in SQL 2000 will work for you.

Go to Top of Page
   

- Advertisement -