开发者

How to generate "Create Table" script, when I only have read only permission?

I have read only permission on a SQL Server 2005 database, and I'm looking to get a table schema locally to work with. With my current a开发者_如何学运维ccess it won't let me right click on the table and choose 'Create Table' to get the script for this.

Is there a way to generate the create table script from a select statement or by some other mechanism?

Thank you!


You could create a linked server on your local machine. Then, you can use select ... into to copy the table, including data:

select  *
into    NewTableName
from    [LinkedServerName].[DatabaseName].dbo.TableName

This will not copy indexes or constraints. To exclude the data, use select top 0 *.


It's a bit long but the script in Script Table Definitions using TSQL could be addapted to work without needing to create the stored procedure mentioned.

I am assuming you are working with SQL Server 2005

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜