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 2005 Forums
 Transact-SQL (2005)
 How to insert

Author  Topic 

ranganath
Posting Yak Master

209 Posts

Posted - 2007-11-02 : 02:27:18
hi

i have a problem that to insert into Table

i will send '1,2,3# 4,5,6# 7,8,9'

My Output like this
col1 col2 col3
1 2 3
4 5 6
7 8 9

how to split and to insert into Table

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-02 : 02:33:14
[code]DECLARE @STR varchar(100)

SELECT @STR = '1,2,3# 4,5,6# 7,8,9'

SELECT dbo.fnParseString(-1, ',', data) AS col1,
dbo.fnParseString(-2, ',', data) AS col2,
dbo.fnParseString(-3, ',', data) AS col3
FROM
(
SELECT LTRIM(Data) AS data
FROM fnParseList('#', @STR)
) d
-- get the UDF FROM http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033[/code]


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

Go to Top of Page
   

- Advertisement -