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
 General SQL Server Forums
 New to SQL Server Programming
 Splitting a dataset using a function

Author  Topic 

Lionheart
Starting Member

41 Posts

Posted - 2010-11-29 : 16:54:42
Hi All

I have a data set which I am feeding into a stored proc which has 15 columns of data, comma separated, with the end of each row being delineated with a semi-colon.

Does anybody have some code that will allow me to post this straight into a table?

Thx

LH

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2010-11-29 : 17:45:17
Have a look at Bulk Insert , but you need to make the destination table first.

http://msdn.microsoft.com/en-us/library/ms188365.aspx

BULK INSERT TableName
FROM 'c:somefile.csv'
WITH
(
FIELDTERMINATOR =',',
ROWTERMINATOR = ':\n'
)




Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

Lionheart
Starting Member

41 Posts

Posted - 2010-11-30 : 05:24:24
Thanks, but I am trying to do it without the use of a csv file. I have the method above, but what I am working on is creating the dataset using vba in Excel and feeding it into a stored proc as a variable in the format I initially mentioned and having the code in the proc split it into the columns in the table.

Thx

LH
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2010-11-30 : 06:47:06
Sounds like the hardest way possible to import excel data. DTS and SSIS both import excel pretty easily without having to write any additional code/procedures. Without more info..can't provide much help. What is the destination structure? how are you sending the data to the stored procedure? You can use VBA to send it directly to the server as well..but www.vbaexpress.com would be more help with that end...



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

Lionheart
Starting Member

41 Posts

Posted - 2010-11-30 : 07:35:59
Thanks...I'll give that a shot.

LH
Go to Top of Page
   

- Advertisement -