Home All Groups Group Topic Archive Search About

using parameter for filename in stored procedure

Author
3 Aug 2006 11:00 AM
Netherxx
Hi there,

I am trying to use a filename from a vb.net application as a parameter
in a stored procedure. However, i don't know exactly how to put the
parameter into the stored procedure. I know how to configure the stored

procedure with 'normal' parameters, but with a filename as a stored
procedure i am stuck.


I have written the following stored procedure, but it keeps coming up
with syntax errors, so i assume i am on the right way.


ALTER PROCEDURE dbo.sp_bulkimportcust
@PCWrite varchar(1000) = NULL


AS
DECLARE @Work varchar(8000)


        TRUNCATE TABLE Customers
Set @WORK = 'BULK INSERT Customers FROM ' +  @PCWrite + ' with
(fieldterminator = ';')'
                RETURN
EXECUTE (@WORK)


Can anyone help me?


Thx

Author
3 Aug 2006 11:10 AM
Locky
Netherxx wrote:
Show quote
> Hi there,

> ALTER PROCEDURE dbo.sp_bulkimportcust
> @PCWrite varchar(1000) = NULL
>
>
> AS
> DECLARE @Work varchar(8000)
>
>
>         TRUNCATE TABLE Customers
> Set @WORK = 'BULK INSERT Customers FROM ' +  @PCWrite + ' with
> (fieldterminator = ';')'
>                 RETURN
> EXECUTE (@WORK)

create PROCEDURE dbo.sp_bulkimportcust
@PCWrite varchar(1000) = NULL


AS
DECLARE @Work varchar(8000)


         TRUNCATE TABLE Customers
Set @WORK = 'BULK INSERT Customers FROM ' +  @PCWrite + ' with
(fieldterminator = '';'')'
                    ^^ ^^
                 RETURN
EXECUTE (@WORK)

double-quote in strings....
Author
3 Aug 2006 11:46 AM
Netherxx
Thanks alot! just overlooked the double quotes!

Much appriciated !

Regards,

Rolf

Locky schreef:

Show quote
> Netherxx wrote:
> > Hi there,
>
> > ALTER PROCEDURE dbo.sp_bulkimportcust
> > @PCWrite varchar(1000) = NULL
> >
> >
> > AS
> > DECLARE @Work varchar(8000)
> >
> >
> >         TRUNCATE TABLE Customers
> > Set @WORK = 'BULK INSERT Customers FROM ' +  @PCWrite + ' with
> > (fieldterminator = ';')'
> >                 RETURN
> > EXECUTE (@WORK)
>
> create PROCEDURE dbo.sp_bulkimportcust
> @PCWrite varchar(1000) = NULL
>
>
> AS
> DECLARE @Work varchar(8000)
>
>
>          TRUNCATE TABLE Customers
> Set @WORK = 'BULK INSERT Customers FROM ' +  @PCWrite + ' with
> (fieldterminator = '';'')'
>                     ^^ ^^
>                  RETURN
> EXECUTE (@WORK)
>
> double-quote in strings....

AddThis Social Bookmark Button