Home All Groups Group Topic Archive Search About

Columns referenced inside store procedures may not exist issue

Author
20 Aug 2005 1:33 AM
Peter
I have a stored procedure which I want to be added to 2 different databases.
However, I run into an issue that some statements in the stored procedure are
referencing columns only exist in one of the databases. I want to SQL Server
to parse those statements only if those columns exist in the database.


Thanks.

Author
20 Aug 2005 2:38 AM
Louis Davidson
Sorry, this is not how it works (you could use dynamic SQL, but that is not
generally a good option).  You will need to make two versions of the
procedure or add the columns in the other database.

--
----------------------------------------------------------------------------
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP


Show quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:75D605C4-6843-4E83-8E49-39252BA25FEA@microsoft.com...
>I have a stored procedure which I want to be added to 2 different
>databases.
> However, I run into an issue that some statements in the stored procedure
> are
> referencing columns only exist in one of the databases. I want to SQL
> Server
> to parse those statements only if those columns exist in the database.
>
>
> Thanks.

AddThis Social Bookmark Button