Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays in T-SQL?

Status
Not open for further replies.

Waynest

Programmer
Joined
Jun 22, 2000
Messages
321
Location
GB
Hello all

Is it possible to use arrays of variables within a stored procedure, I dont seem to be able to locate anything in the online help. I was planning to create series of dates using a nested loop and the code is going to be ridiculously long if I cant use subscripts!

An example of syntax would be great if it is 'doable'.

TIA
Wayne
 
T-SQL doesn't have array variables. However, you can simulate arrays with comma separated variables (or another delimiter of choice.) See the following article.


If you have SQL 2000, you can use table variables to simulate arrays. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Another possibility (at least for SQL 7) is to use a temp table. A local temporary table only lasts for the length of the current session and can be a good way to dump an array of values.

Dave Robinder, MCSD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top