views:

48

answers:

2

I'm wondering if is it possible to copy one table definition from .mdf file to create it in SQL Server and could it be done in Visual Studio 2010?

It doesn't matter if I'll do it by some kind of wizard or retrieve a SQL query with a command like "Create Table...". I just want to have one table which I created in mdf file in database on my server.

PS I don't want to copy its content and I don't want to copy whole database. Just one table definition.

+1  A: 
SELECT *
    INTO YourNewTable
    FROM YourOriginalTable
    WHERE 1=2

This will create the structure but will not copy any data (since nothing could possibly satisfy the WHERE clause). Note that this method will not create any indexes/constraints/triggers. Those would need to be scripted out and applied separately.

Joe Stefanelli
A: 

You can generate a table creation script usin management studio if you can attach the db for a minute.

Jason Goemaat