By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,415 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,415 IT Pros & Developers. It's quick & easy.

Passing a file path to a SP

P: n/a
I'm trying to write a SP that
accept in input a parameter with the name
of a file (with complete path)
but I noticed some problems....

It's right this way? Thanks!

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[BI]
@FileToImport nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @SQL nvarchar(200)

SET @SQL = "BULK INSERT tmptable FROM '"+@FileToImport+"'"
EXEC (@SQL)
END
Apr 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try enclosing the literal in single-quotes. Specify 2 single-quotes inside
the literal where you have an embedded single-quote:

SET @SQL = 'BULK INSERT tmptable FROM '''+@FileToImport+''''

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Maury" <ma*********************@gmail.com> wrote in message
news:qS*********************@twister1.libero.it...
I'm trying to write a SP that
accept in input a parameter with the name
of a file (with complete path)
but I noticed some problems....

It's right this way? Thanks!

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[BI]
@FileToImport nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @SQL nvarchar(200)

SET @SQL = "BULK INSERT tmptable FROM '"+@FileToImport+"'"
EXEC (@SQL)
END

Apr 3 '06 #2

P: n/a
Dan Guzman ha scritto:
Try enclosing the literal in single-quotes. Specify 2 single-quotes inside
the literal where you have an embedded single-quote:

SET @SQL = 'BULK INSERT tmptable FROM '''+@FileToImport+''''

IT'S OK!!!!
Thank you very very much.....
(and sorry I'm a newbie in SQL Server)
Apr 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.