Sunday, March 11, 2012

Create procedure

Hi

I try to create a very simple stored procedure,

CREATE PROCEDURE Importera_fil

@.fil varchar

AS

INSERT INTO XMLFaktura(Faktura)

SELECT * FROM OPENROWSET

(Bulk '@.fil', SINGLE_CLOB) AS DocumentID

but I get an errormessage when I try to create it,

Msg 4860, Level 16, State 1, Procedure Importera_fil, Line 4

Cannot bulk load. The file "@.fil" does not exist.

So my question is, how can i create the procedure?

Thanks for any help

The parameters of most DDL statements, OPENROWSET, OPENQUERY etc cannot be passed as variables. You have to specify the file name using literals directly. This is a limitation in the language feature. So in order to use @.fil you need to use dynamic SQL to form the SELECT statement and execute it.

No comments:

Post a Comment