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 |
firasazzi
Starting Member
2 Posts |
Posted - 2010-07-29 : 09:16:12
|
i'm trying to use bulk insert but i have multiple files with diffrent locations i tried to use variable for the pathlike thisBULKINSERT #ImportedFlatFROM @vchPath WITH(FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')but an error apeared:-sg 102, Level 15, State 1, Procedure UpdateMasterData, Line 35Incorrect syntax near '@vchPath'.Msg 319, Level 15, State 1, Procedure UpdateMasterData, Line 36Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.fazzi |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-29 : 09:57:55
|
Try dynamic sql. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2010-07-29 : 10:24:47
|
[code]DECLARE @sql varchar(8000), @ImpoprtedFlat varchar(8000)SET @ImpoprtedFlat = 'd:\myFail99.dat'SET @sql = 'BULK INSERT #ImportedFlat FROM ' + @ImpoprtedFlat + 'WITH(FIELDTERMINATOR = '','',ROWTERMINATOR = ''\n'')'SELECT @sql[/code]However, Dynamic SQL executes in it's own thread, and will not see your temp table. Either make it a permanent table, or a global temp tableBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
|
|
firasazzi
Starting Member
2 Posts |
Posted - 2010-08-01 : 02:48:19
|
thx webfred and X002548 for ur replays it helps me alot now it works finebest regrads,Firas azzifazzi |
|
|
|
|
|
|
|