C
C
CodeInside2018-02-20 12:17:58
SQL
CodeInside, 2018-02-20 12:17:58

How to convert received file address in stored procedure for BULK INSERT?

I am writing a stored procedure that takes the address of a data file and the address of the corresponding .fmt file.

CREATE PROCEDURE InsertCitiesFromFile
@importDataFilePath NVARCHAR(MAX),
@formatFilePath NVARCHAR(MAX) AS
BULK INSERT City
FROM @importDataFilePath
-- дальше уже не важно

The development environment shows that something is wrong near @importDataFilePath. That is, you cannot get the path to the file from an NVARCHAR type parameter. Writes that an ID, INTEGER, QUOTED_ID, STRING, or TEXT_LEG is expected. Tried, for example, to set @importDataFilePath data type to STRING (or TEXT_LEG). But the environment writes that this is an incorrect type for the parameter. How to pass through a procedure parameter an address that can be used in BULK INSERT?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2018-02-23
@d-stream

Alas... BULK INSERT, OPENROWSET do not accept variables as arguments... alas

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question