I need to be able to get the CREATE scripts for existing tables within SQL Server 2008. I assume I can do this by querying the sys.tables somehow, however this isn't returning me the CREATE script data.
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
Try sp_helptext Equivalent for Tables?
"Easiest way is to use the built-in feature of SQL Management Studio" but... I have resolved it with a function and a couple of procedures. For example, to obtain the create table for a table named 'table_name', you have to execute just the procedure called sp_ppinScriptTabla:
Here is the tsql script code:
You forgot to include the stored procedure or function script for
sp_ppinCamposIndice
Try this (using "Results to text"):
Cheers,
Easiest way is to use the built-in feature of SQL Management Studio.
Right-click the database, go to tasks, Generate Scripts, and walk through the wizard. You can choose what objects to script, and it'll make it all for you.
Now if you are trying to make your OWN script to do the same thing, you're probably up for a lot of work...
Use the SSMS, easiest way You can configure options for it as well (eg collation, syntax, drop...create)
Otherwise, SSMS Tools Pack, or DbFriend on CodePlex can help you generate scripts