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)
 Created variable when needed (dynamic)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-02-23 : 09:08:59
Rashed writes "Hi,

Is it possible to create dynamic variables in SQL Server 2000? I mean, I want my stored procedure to create variable and declare it, only when needed.

For example,

I have got a variable called, @str0 of type varchar(4000). When the limit is full then it will create a variable @str1 of type varchar(4000). When that limit is full then it will create another variable @str2, @str3, @str4 ….

Can someone please advice how can I do it in SQL server 2000?

Thanks in advance
Rashed"

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-02-23 : 10:11:27
I think u need a dynamic array, but I doubt the T-SQL has that (even the arrays, I'm not sure)

How about some orkarounds
eg1. Keeping only one variable and holding data in that and do the operation u need and get the next data chunk to the same variable and so on.

eg2. Inserting the data to a table (may be a temp table) as a variable name as one column value and the varchar(4000) as the other column value and querying the table whenever u want to access any variable
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2006-02-23 : 10:26:25
Yes, 'dynamic array' - sounds like a table to me!

Mark
Go to Top of Page
   

- Advertisement -