SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Bulk Insert


Bulk Insert

Author
Message
Justin-14543
Justin-14543
SSC-Addicted
SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)

Group: General Forum Members
Points: 401 Visits: 154
Use Exec stmt
Exec(@some_string )

Give me a fish, you feed me for a day! Teach me to fish, you feed me for a life time.
rachel
rachel
Old Hand
Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)

Group: General Forum Members
Points: 332 Visits: 9
Problem with quotes in the Bulk Insert - normally I use what you suggested

BULK INSERT temp FROM ''' (plus) @file (plus) '''

But in this case - my actual filename has quotes around it. It comes from a mainframe and for whatever reason thats the way the frame creates the filenames.

I tried using the "normal" way - but I get the following error:

Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near 'ECM'.
(the filename is 'ECM.DM.LIST.0001000037.TEST' (quotes and all)

The actual syntax of the bulk insert (at run-time) is:

BULK INSERT temploadswbt FROM '\\Chicagofs\Ameritech\Sbc\'ECM.DM.LIST.0001000037.TEST''
WITH (
FORMATFILE = 'g:\sbcdata\swbtpb_new.fmt' )

anyone have any ideas? Thanks!!



Deuce
Deuce
Mr or Mrs. 500
Mr or Mrs. 500 (580 reputation)Mr or Mrs. 500 (580 reputation)Mr or Mrs. 500 (580 reputation)Mr or Mrs. 500 (580 reputation)Mr or Mrs. 500 (580 reputation)Mr or Mrs. 500 (580 reputation)Mr or Mrs. 500 (580 reputation)Mr or Mrs. 500 (580 reputation)

Group: General Forum Members
Points: 580 Visits: 14
replace(filename, '"', '')



rachel
rachel
Old Hand
Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)Old Hand (332 reputation)

Group: General Forum Members
Points: 332 Visits: 9
I am referencing an actual file that has quotes in the filename - if I take the quotes out of the variable holding the filename - it won't match the actual filename



5409045121009-7368
5409045121009-7368
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2360 Visits: 1
Need another ' at the end try

Select '\\Chicagofs\Ameritech\Sbc\''ECM.DM.LIST.0001000037.TEST'''
and you get

\\Chicagofs\Ameritech\Sbc\'ECM.DM.LIST.0001000037.TEST'
which is what T-SQL will be using internally.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search