Matthew Doyle
Matthew Doyle

Reputation: 1065

Strange behavior when modifying tables or procedures in SQL Server 2008 Management Studio

This is some weird behavior...

Whenever I script certain tables (using CREATE TO...) or edit stored procedures (using modify in the right click context menu) I sometimes get really weird results... For example, scripting most tables gives me:

CREATE TABLE [dbo.].[TableINeverAskedFor]
...

CREATE TABLE [dbo].[TableIWant](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](128) NOT NULL,
    [ModuleID] [int] NOT NULL,
    [OtherInfo] [int] NOT NULL,
CONSTRAINT [PK_ModuleDefinitions] PRIMARY KEY NONCLUSTERED 

CREATE TABLE [dbo.].[TableINeverAskedFor]
...

ALTER TABLE [dbo].[TableWhichHasNothingToDoWithMyTable] ADD  CONSTRAINT [FK_WhyDoesThisHappen?]  DEFAULT ((0)) FOR [ID]

Stored procedures are even more weird... the bigger the sotred procedure, the more alter scripts I get, just like above. It's really annoying and I am afraid I'm going to do something stupid and not pay attention one day.

Relevant info:

EDIT: It's not that weird... I can see it being useful for table creation. Editing a stored procedure though, that was what was very confusing to me.

Upvotes: 0

Views: 171

Answers (1)

Aaron Bertrand
Aaron Bertrand

Reputation: 280262

In Management Studio go to Tools > Options > SQL Server Object Explorer > Scripting and change Generate script for dependent objects to false. False is the default so you did ask for this at some point. ;-)

Upvotes: 1

Related Questions