RE: Using a column variable in an Insert Stored procedure
From: Pam Davey (PamDavey_at_discussions.microsoft.com)
Date: 08/31/04
- Next message: Devil Garfield: "2 Urgent Problems need to solve"
- Previous message: SHP_at_work.com: "Performance of Like in the Query"
- In reply to: Clint Colefax: "RE: Using a column variable in an Insert Stored procedure"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 30 Aug 2004 21:13:05 -0700
Thank you for the suggestion. I'll definitely try it.
FYI though, dbo.CustomTable does exist. I should have included that this is
actually the content of the @Table variable (sysname) that the sp sends to
the user defined function. The function is actually retrieving the column
names from that table(CustomTable). I'll be happy to try your suggestion but
I'm at a loss as to why SQL Server is returning this error.
Thanks again.
"Clint Colefax" wrote:
> Does CustomTable exist?
>
> Generally this error message is telling you that the specified object does
> not exist.
>
> Even so, I don't think what you are trying to do will work anyway. You may
> need to look into creating an add hoc sql statement using the sp_executesql
> procedure. With this you can build a script in a nvarchar variable, then pass
> this to the procedure to execute.
>
> "Pam Davey" wrote:
>
> > I'm not sure if this is the correct place for this msg..
> >
> > I'm a bit new to SQL server and here's what I have:
> >
> > I've created a stored procedure in SQL Server 2000 which has a parameter
> > @Table sysname.
> > The sp calls a scalar user defined function and passes it the @Table
> > variable. The function returns a variable (@Columns varchar(8000)) which
> > lists the column names in @Table in this format (col1, col2, ...)
> > Back in the sp I use the @Columns variable in an insert statement this way:
> >
> > INSERT INTO MyDB.dbo.CustomTable
> > (@Columns)
> > VALUES
> > (@Value1, @Value2...)
> >
> > The syntax checks in the sp and it works nicely up to the Insert statement
> > at which point SQL Server returns the error: Invalid object name
> > MyDB.dbo.Custom
> >
> > What am I overlooking?
> >
> > Thank you for any help.
- Next message: Devil Garfield: "2 Urgent Problems need to solve"
- Previous message: SHP_at_work.com: "Performance of Like in the Query"
- In reply to: Clint Colefax: "RE: Using a column variable in an Insert Stored procedure"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|