Home > Archive > Microsoft SQL Server forum > April 2006 > Passing a file path to a SP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Passing a file path to a SP
Maury

2006-04-03, 7:33 am

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
Dan Guzman

2006-04-03, 7:33 am

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" <maurizio. alberti_TOGLI_@gmail
.com> wrote in message
news:qS7Yf.64843$A83.1587071@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



Maury

2006-04-03, 9:30 am

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)
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com