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)
 Row to column

Author  Topic 

niranjankumark
Posting Yak Master

164 Posts

Posted - 2007-10-23 : 08:09:13
I have a some value in one variable.
ex : @val = 1,2,3,4,5,6

This has to be insert in to single column at one table(table variable).

table_name.column_name

1
2
3
4
5
6




khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-23 : 08:24:24
see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830&SearchTerms=CSVTable


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-23 : 08:34:54
If there are only numbers then join with numbers table

Insert into targettable(column_name)
Select number from numbers
where where ','+@val+',' like '%,'+cast(n as varchar(10))+',%'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -