Friday, March 30, 2012

Is there a System Stored Procedure that scripts tables?

Hello
I wonder if I can generate the "CREATE TABLE" sentence given the name of a table by means of a stored procedure.
Thanks a lot.Hello

I wonder if I can generate the "CREATE TABLE" sentence given the name of a table by means of a stored procedure.

Thanks a lot.

I think you need the Server Management Objects (SMO) to do what you are thinking of. SMO works in SQL 2005. There's an earlier version of it in SQL 2000, but for the life of me, I can't remember the name right now.

Regards,

hmscott|||I imagine you could create one by using Profiler to examine what happens when you right click a table in Enterprise Manager select "All Tasks -> Generate SQL Script -> Preview". Be aware ahead of time, it's not a one-step process...|||This free console app I wrote may be of use to you. it will generate scripts for all objects in any 2000 or 2005 database. open source so you can tweak it if you want. it uses SMO.

I wrote it as a way to easily export the DDL for a database for checkin to a source control system.

http://www.elsasoft.org/tools.htm

hope it's useful to you!|||Thanks a lot!sql

No comments:

Post a Comment