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 |
|
Mike_007
Starting Member
8 Posts |
Posted - 2007-08-20 : 09:40:10
|
| Hi AllThis is my first official post...very exciting:)OK....I need to split a string, based on comma delimetrs, into columns of a table.I am using SQL Server 2005.The plan is to use webmethods (Integration Software) to receive a flat file, loop through the records in that flat file and during each iteration of the loop call a SQL stored procedure that will split the record, based on comma delimetrs, into columns of a table.A typical record will look like this:AP05-07,ACTUAL,ZA01,......I have looked at some of the past solutions to this type of post, but am battling to understand....So if its possible, is there a simple way to create a stored procedure that will do this?Many thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-20 : 09:43:32
|
BCPBULK INSERTOPENROWSET E 12°55'05.25"N 56°04'39.16" |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Mike_007
Starting Member
8 Posts |
Posted - 2007-08-21 : 04:00:50
|
| Thanks for the quick replies...Ok so I am now playing with the bulk insert command...I have created a file that contains the following text:Michael,is,a,kingI have saved this file on the root of C.I have created a table called Test with the following fields:Michael[Is]AKingThe idea is to insert each field of the file into each of the columns above.My Bulk Insert command looks like this:BULK INSERT ABC.dbo.Test FROM 'c:\Bulk.txt' WITH ( CODEPAGE = 'ACP', DATAFILETYPE = 'char', ROWTERMINATOR = ',' )And I get these errors:Msg 4832, Level 16, State 1, Line 1Bulk load: An unexpected end of file was encountered in the data file.Msg 7399, Level 16, State 1, Line 1The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.Msg 7330, Level 16, State 2, Line 1Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".Please excuse my ignorance, Im still bumbling my way around these type of operations..Thanks for the help!! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-21 : 04:13:41
|
| Make sure you closed the file before running bulk insertMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|