June 1, 2016 at 1:29 am
Hi,
I trying to generate table create script through sql query, for my procedure i'm passing table name and database name as an input parameter it should give the result of the table script and the result of the script should save in any of the local folder of our system (Local path also an input parameter) this is my requirement. Is this possible to get the script and saved to an particular folder.
June 1, 2016 at 1:42 am
Why do you choose the harder way? You have that in SSMS: right click on a database - > tasks -> generate scripts and then you have the many options - which is essentially important.
Igor Micev,My blog: www.igormicev.com
June 1, 2016 at 3:22 am
I wouldn't try doing this through T-SQL. Instead, look to Powershell. There are tons of examples of exactly this type of on demand script generation using PowerShell.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
June 1, 2016 at 3:49 am
Yes, if you have to go with codes, then PowerShell is the way that offers you easily achieve what you can do with the UI in SSMS.
Scripting other objects like constraints, indexes, triggers as part of tables could be very hard with t-sql (and you're not sure whether you'd done it well).
Igor Micev,My blog: www.igormicev.com
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply