| Author |
Passing a file path to a SP
|
|
|
| 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
| |
|
| 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)
|
|
|
|