|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, January 08, 2009 9:26 AM
Points: 1,
Visits: 2
|
|
I am trying to build a script using Microsoft Management Studio that adds in all the primary keys, indexes, and defaults without creating the tables themselves. That is, I want to produce ALTER statements. Actually, Enterprise manager's "Generate script" creates all of these statements when the tables are checked and "Generate the CREATE command for each object" is unchecked. When I try to create a similar script using SQL Server 2005 Management Studio, it doesn't output anything at all! Perhaps this is a bug. (Settings: Script Create = FALSE, Script Indexes = TRUE, Script Primary Keys = TRUE, Tables = Checked). Try it yourself and you'll see that the M.Studio produces no output whatsoever! The reason for the above is that we have some clients who already have the required tables. However, they never had primary keys and indexes installed, for whatever reason. Therefore, we do not want to create the tables (they are already there), but simply use ALTER statements to add in primary keys to the tables selected.
An example of the type of script I want Managment Studio to produce:
ALTER TABLE [dbo].[HOMEMastRoomData] ADD CONSTRAINT [DF__Temporary__RoomT__0B27A5C0] DEFAULT (0) FOR [RoomType], CONSTRAINT [DF__Temporary__Accou__0C1BC9F9] DEFAULT (0) FOR [AccountingType], CONSTRAINT [DF__Temporary__Activ__0D0FEE32] DEFAULT (0) FOR [ActiveYN], CONSTRAINT [DF__Temporary__Remov__0E04126B] DEFAULT (0) FOR [RemovedYN], CONSTRAINT [PK_HOMEMastRoomData] PRIMARY KEY NONCLUSTERED ( [RowID] ) ON [PRIMARY] GO
CREATE INDEX [IX_HOMEMastRoomData_RoomType] ON [dbo].[HOMEMastRoomData]([RoomType]) ON [PRIMARY] GO
|
|
|
|