Friday, March 30, 2012

Question About Scripting Objects

Hello all,

I was just using Management Studio to script objects on one server to create on another server and I noticed an issue that I need assistance with. When you right-click a table and choose to Script Table As --> Create To --> ..., it scripts the Create Table fine, but if the table has any Primary Keys, Foreign Keys, Constraints, etc., these objects don't get scripted with the Create Table. You have to manually script these objects as well.

I believe in SQL Server 2000, you had the choice of which objects to get created when you wanted to generate the script. Is there an easy way to do this in SSMS? If so, how?

Thanks,

Jason

Nevermind ... it's working now. The developer was adding the PK to the table while I was scripting it so there wasn't a PK to generate at the time of my scripting. Once he added the PK, I was able to generate the script, which included the PK as part of the Create script.

Jason

|||

I have a similar problem. I need to create scripts with the DROP object syntax at the top. This was possible in SQL-2000.

Any help in setting these options for SQL-2005 would be great.

-Rajiv

|||

Rajiv,

I think in SQL Server 2005 you have to generate the DROP independent of the CREATE. I don't think there is an option to generate both commands at once like there was in SQL Server 2000. I could be wrong though, but I haven't been able to find anything comparable in SQL Server 2005. Maybe Microsoft will correct that in a future service pack.

Jason

sql

No comments:

Post a Comment