开发者

sql server script generater stored proc

anyone know of such stored procs to generate scripts for tables/indexex/vie开发者_StackOverflow中文版ws/sp's etc.


The GUI (SQL Server Management Studio) is just a thin shell around the SMO. All the scripting power is inside the SMO. Use the Scripter class. Have a look at this basic intro to SMO scripting: SQL Server: SMO Scripting Basics.


Views and SPs are relatively easy since the code is in the syscomments/INFORMATION_SCHEMA.ROUTINES.

I've created one for tables, but it's not particularly complete - and in fact, it only actually generates the appropriate CREATE TABLE statement for a completely different platform - Teradata, so it turns the PRIMARY KEY into a UNIQUE PRIMARY INDEX (Teradata allows both a PRIMARY KEY and a PRIMARY INDEX, but does not allow the PRIMARY KEY - or any index - to have the same columns as any other index).

I'm not sure there are any standard ones out there, but it would just be a matter of all the little things - getting all the extended properties on columns tables and indexes, etc.


I don't know of any stored procs for this but Microsoft has the SQL Server Database Publishing Wizard to generate scripts (structure and data).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜