I want to generate create table script of already created table in my live database.
I know we can generate scripts using right click on table and click on 'script table as' menu and script will be generated. Because my live db UI is running very slow.
I want to do same process using SQL query. is there any way??
Open the SQL Server Management Studio. In the Object Explorer, expand Databases, and then locate the database that you want to script. Right-click the database, point to Tasks, and then select Generate Scripts.
If you are looking for a TSQL solution, it is quite verbose, as this example shows.
A shorter alternative would be using the SMO library (example)
(I originally answered this here, but SQL Server-only devs probably do not relate the question title to this problem)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With