Script fails as sp references column that no longer exists

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

Script fails as sp references column that no longer exists

Postby prw » Thu Jan 24, 2013 5:23 pm

Hi,

During our build process we have created a stored procedure that inserts data into a table in another database. This was created and run successfully. Since then a column was dropped from this table and the sp. updated to reflect this.

Using SQLCompare to produce the deployment script it successfully scripts the creation of the sp when it was first created followed by a script that performs an ALTER statement to change the sp.
During deployment the script fails at the part where the sp is first created. This is because the column referenced in the table no longer exists, and so the sp cannot be created.

How can this be overcome during the deployment process. I have checked previous forum posts but can't find anything. I would have thought this was a common occurrence so I am overlooking a very simple option ?
prw
 
Posts: 2
Joined: Tue Jun 12, 2012 4:03 pm

Postby David Atkinson » Thu Jan 24, 2013 6:40 pm

This is a SQL Server limitation. It is not possible to create a procedure that references a column that doesn't exist. Interestingly SQL Server lets you create a procedure that references a table that doesn't exist!

Why can't you simply drop the procedure since it is now "invalid" and can't run anyway?

(SQL Prompt has a "find invalid objects" feature that will help you track these down)
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase


Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 1 guest