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.
| Author |
Topic |
|
zany
Starting Member
4 Posts |
Posted - 2007-07-19 : 13:45:04
|
I have a comma delimited string with a length of more than 10,000 characters. I want to insert these comma delimited values into a table. How can I achieve this?Here is what I have tried. It works fine if the input string is less than 8000 characters.-- OrderIDs is the user input-- sample input string '2345678, 3456789, 4567890, 5678901,...'DECLARE @OrderIDs varchar(8000)CREATE TABLE #t (OrdID int not null)DECLARE @SQL VARCHAR(8000)SELECT @SQL = 'insert into #t select '+REPLACE (@OrderIDs, ',' , ' union select ')-- Load values from comma delimited string into a tableEXEC ( @SQL )any help is highly appreciated.Thanks  |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-07-19 : 13:48:35
|
| This question has been answered several times in this forums. Do a search and you wil find dozens of links.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-19 : 13:49:10
|
| look around here for splitter functions._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|