Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bulk insert
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Miscellaneous
Thread ID:
01034449
Message ID:
01034482
Views:
19
>Hi All,
> I am using the bulk insert command to insert data into temp table. However, when I execute the command I am getting the following error:
>
>Server: Msg 4861, Level 16, State 1, Line 1
>Could not bulk insert because file 'C:\Temp\Sql\Udf_Encry_Field.sql' could not be opened. Operating system error code 3(The system cannot find the path specified.).
>
>Here is my code
>
>BEGIN
>
> DECLARE @SQLsp as NVARCHAR(4000),
> @PathFileName nVarchar(2000),
> @SQL varchar(2000)
>
> Set @PathFileName = 'C:\Temp\Sql\Udf_Encry_Field.sql'
>
> --Temporary table for getting the SP
> if object_id('tempdb..#tmpSP') IS NOT NULL
> DROP TABLE #tmpSP
>
> CREATE TABLE #tmpSP (spText NVARCHAR(4000))
>
> --Gets the SP from .sql to Temp table
> SET @SQL = 'BULK INSERT #tmpSP FROM ' + char(39) + @PathFileName + char(39)
> Exec (@SQL)
> --Get the complete SP to a Variable to execute it
>
> --SELECT @SQLsp = spText FROM #tmpSP
>
> --Execute the SP
> --EXECUTE sp_executesql @SQLsp
>
>END
>Please help!!!

Is the file on the SQL Server machine or your local pc? If the file is local on your pc, then you will need to either map from the database server to your pc and change the file path accordingly or move the file to the server.

Kurt
Previous
Reply
Map
View

Click here to load this message in the networking platform