公告
财富商城
积分规则
提问
发文
2020-07-27 04:49发布
姐就是有狂的资本
How do I generate sql database script using code c# or sql code?
we can use the Generate Scripts option from ssms but how do I generate sql database script using code any help?
Generate Scripts
ssms
You should use SQL Server SMO (Server Management Object) that includes exactly the features you're looking for. You can script single database, or specific objects. Actually, that's how SSMS does it.
Blog post: http://weblogs.asp.net/shahar/generating-sql-backup-script-for-tables-amp-data-from-any-net-application-using-smo
MSDN sample for scripting database: https://msdn.microsoft.com/en-us/library/ms205825.aspx
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.scripter.aspx
最多设置5个标签!
You should use SQL Server SMO (Server Management Object) that includes exactly the features you're looking for. You can script single database, or specific objects. Actually, that's how SSMS does it.
Blog post: http://weblogs.asp.net/shahar/generating-sql-backup-script-for-tables-amp-data-from-any-net-application-using-smo
MSDN sample for scripting database: https://msdn.microsoft.com/en-us/library/ms205825.aspx
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.scripter.aspx