I cant figure out how to set the lastrow parameter to a var. This var would be sent in from a c# program. Below is what I'm trying to do but I get a syntax error on the @.lastRow.
is there a way to do this
ALTER PROCEDURE [dbo].[p_temp]
--@.lastRow int
AS
BEGIN
--SELECT <@.Param1, sysname, @.p1>, <@.Param2, sysname, @.p2>
BULK INSERT PHX_WCISFile
FROM 'C:\100.TXT'
WITH
(
FIRSTROW = 2,
LASTROW = @.lastRow;
MAXERRORS = 20,
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
END
I believe that BCP is unable to utilize parameters in that manner.
You could, however, create the entire BULK INSERT statement as a string and execute it using EXEC(). That would allow you to pass in parameters to substitute in the statement.
|||Arnie is correct. Unforunitely you will need to use dynamic SQL to do this.
No comments:
Post a Comment