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:
- I have SQL Server 2008 R2 installed, a new install.
- I have a few developers in my shop experiencing similar problems.
- I also have a SQL Server 2008 box (no R2) doing the same thing.
- My instance is updated with SP1 and theirs aren’t.
- We can also replicate the issue on multiple databases.
- Our production server is not giving us the same issue.
- Some stored procedures and tables don’t have this problem however the same stored procedures and tables can be replicated. It’s not a random issue.
- I have no plugins installed.
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.
In Management Studio go to
Tools > Options > SQL Server Object Explorer > Scriptingand changeGenerate script for dependent objectsto false. False is the default so you did ask for this at some point. 😉