SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On



Script Table As misses or missing a column Expand / Collapse
Author
Message
Posted Wednesday, June 17, 2009 5:03 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, September 02, 2009 3:23 PM
Points: 1, Visits: 14
Microsoft SQL Server 2005 - 9.00.3068.00 (Intel X86) Feb 26 2008 18:15:01 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)

Follow these steps:
1. Open SQL Management Studio.
2. Break down the tree for a database to a list of tables.
3. Right click and choose script as on the table. Script an insert to a new query window.
4. Run a sql script that inserts a column with a varchar(300) and default (not sure if the default changes anything).
5. Perform step 3 again.
You will notice the new column is not in the 1st create table statement!!! Instead it is in an alter table statement just under the main create table statement!!
SQL SERVER BUG!!! Anybody know a workaround?

This is causing issues not only with ad hoc scripting, but also in tools that compare and script differences.
Post #737078
Posted Wednesday, June 17, 2009 7:55 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 12:26 PM
Points: 1,669, Visits: 2,045
No, it's not a bug.

Before you run step 3 again, right-click on the table and select "Refresh".
Then, when you run step 3, you'll have the column.

The GUI tool (SSMS) only get's the table definition once. If SSMS changes the structure, it knows to refresh it's definition. If you change it behind the scenes, then you need to force the refresh.


Wayne
For better assistance in answering your questions, click here.
For performance problems, please read this.
For common date/time routines, click here.
For CROSS-TABS and PIVOT tables, click on Part 1 and Part 2.
Post #737104
« Prev Topic | Next Topic »


Permissions Expand / Collapse