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 |
|
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2008-07-22 : 10:17:03
|
| dear All,When I run this sql script it shows some errorsql = "INSERT INTO SMSs (TagName, SmsBody, MobileNumber, Status) SELECT e.TagName,e.SmsBody,v.columnname,e.Status FROM Events e CROSS JOIN (SELECT * FROM OPENROWSET (BULK ''' C:\20080722162219_1.txt ''', SINGLE_BLOB) v WHERE e.Status=0 "Error is : Incorrect syntax near the keyword 'BULK'Here I am just getting TagName, SmsBody, Status from the table Events and getting MobileNumber from the file C:\20080722162219_1.txt and then want to insert all these into SMSs tableSMSs table structure is:Id, TagNmae(varchar), SmsBody(varchar), MobileNumber(varhcar)RegardsShajiCan anybody help me!Shaji |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-22 : 10:34:36
|
| are you using sql 2000 or 2005?BULK option is only in 2005 i guess |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-22 : 10:36:07
|
[code]INSERT SMSs ( TagName, SmsBody, MobileNumber, Status )SELECT e.TagName, e.SmsBody, v.Col, e.StatusFROM Events AS eCROSS JOIN OPENROWSET (BULK 'C:\20080722162219_1.txt', SINGLE_BLOB) AS v(Col)WHERE e.Status = 0[/code]Please remember that the path to the file is not your local path.The path in OPENROWSET is relative to your SQL Server because that's where the code is run. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-22 : 10:36:15
|
| Import the file in the staging table and use that staging table in the queryMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-22 : 10:42:22
|
quote: Originally posted by shajimanjeri Can anybody help me!
You are missing an ending paranthesis for the v derived table.See my example. There is no need for extra paranthesises. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2008-07-22 : 14:55:14
|
| Thanks Mr.Peso,When run I run the script above its shows agian the same.Server: Msg 156, Level 15, State 1, Line 13Incorrect syntax near the keyword 'BULK'."Please remember that the path to the file is not your local path." What does it mean. I have this text file on my C drive. The path is C:\20080722162219_1.txtI don't know whats the issue here? I want to fetch the records from this fileI hope you will give a solution to this pleaseI am using SQL 2000 serverShaji |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-23 : 02:59:30
|
quote: Originally posted by shajimanjeri Thanks Mr.Peso,When run I run the script above its shows agian the same.Server: Msg 156, Level 15, State 1, Line 13Incorrect syntax near the keyword 'BULK'."Please remember that the path to the file is not your local path." What does it mean. I have this text file on my C drive. The path is C:\20080722162219_1.txtI don't know whats the issue here? I want to fetch the records from this fileI hope you will give a solution to this pleaseI am using SQL 2000 serverShaji
Did you read my solution?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|