Mehram
asked on
Bulk Insert update through path value
Dear Experts,
I am using below mentioned query to update text file into database. I need to declare @path in bulk insert statement instead of hard coding. Please help.
Bulk Insert Emp_DB.dbo.intermediary From '\\10.0.0.150\att\txtfile. txt' With (FieldTerminator=',', FirstRow=1, rowterminator ='\n')
Need to do like this
Declare @Path Varchar(100)
Set @Path ='\\10.0.0.150\att\txtfile .txt'
Bulk Insert Emp_DB.dbo.intermediary From @Path With (FieldTerminator=',', FirstRow=1, rowterminator ='\n')
Error:
Msg 102, Level 15, State 1, Procedure UpdateTxtFile, Line 14
Incorrect syntax near '@Path'.
Msg 319, Level 15, State 1, Procedure UpdateTxtFile, Line 14
Incorrect 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.
I am using below mentioned query to update text file into database. I need to declare @path in bulk insert statement instead of hard coding. Please help.
Bulk Insert Emp_DB.dbo.intermediary From '\\10.0.0.150\att\txtfile.
Need to do like this
Declare @Path Varchar(100)
Set @Path ='\\10.0.0.150\att\txtfile
Bulk Insert Emp_DB.dbo.intermediary From @Path With (FieldTerminator=',', FirstRow=1, rowterminator ='\n')
Error:
Msg 102, Level 15, State 1, Procedure UpdateTxtFile, Line 14
Incorrect syntax near '@Path'.
Msg 319, Level 15, State 1, Procedure UpdateTxtFile, Line 14
Incorrect 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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.