Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How To declare a array list in sql server

I have someting like this

select EmailDetailTempId from TableName

It returns a more than one Value so how can i store a more than one value in Array list or Some Variable...


OUTPUT

SQL

VB
1
1
9
8
5
6
2
13
12
14
18
17
19
20
147
167



Thanks in Advance...
Posted
Updated 2-Apr-14 0:32am
v3
Comments
Keith Barrow 2-Apr-14 6:26am    
Can you update your question please, as it stands it doesn't make a lot of sense I think the terminology is confused or (more likely) you've missed some important information.
The select will return [probably] several columns and however many rows in your database, this is how SQL works, so an array list doesn't make sense in this context. Are you executing the SQL from code (e.g. .net/Java) - if so which?
Certainly for .net I wouldn't use an array list as the collection type - I doubt it is still the best choice in Java.
Rahul JR 2-Apr-14 6:32am    
Check it... is it ok now? ??
Keith Barrow 2-Apr-14 6:46am    
Not really - SQL doesn't have an array list. At a stretch an individual row is like an object instance, columns like properties of the object type and the whole table acts as a list. Additionally, a table is a store, properly written it is the only store for this information.

Can you clarify where you want to "store" the "array list" and what you want to do with the information - normally working on SQL you query against the table directly unless the table is *very* large
Ganesh Raja 2-Apr-14 6:27am    
what is the need? can you elaborate your requirement?
instead of using the array list you can declare table and use.

Array are not possible but you could declare temp table in SQL like this:
SQL
DECLARE @MyArray TABLE(MyID INT);
INSERT INTO @MyArray EmailDetailTempId from TableName 
 
Share this answer
 
Use a temporary table, and then
SQL
SELECT * INTO #MyTemporaryTable FROM MyTable
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900