Link to home
Start Free TrialLog in
Avatar of ITCSAdmin
ITCSAdminFlag for United States of America

asked on

How do I create SQL Script to create SQL table including Data for SQL 2008

How do I create SQL Script to create SQL table that includes Data for for an existing SQL 2008 Table. I need this to be able to add the script to my Visual Studio 2008 SQL.txt file for when I publish the project, I havelooked all over the MSDN Library and have NOT been able to find what I am looking for, especially since I do not know the terminology.
Avatar of Eladla
Eladla
Flag of Israel image

The command you are looking for is:
create table as select...
Here is an example:
http://www.faqs.org/docs/ppbook/r25329.htm
Follow below steps
- execute create table query
- run below query in SQL manager for each table ( convert all numeric fields into varchar )
- copy all result in script file and execute each in the script
select 'insert into tUser (uId,uName) values ('+convert(varchar,uId)+','+uName+')' from tUser

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ITCSAdmin

ASKER

Was exactly what I wanted and it actually worked too.
Thanks

ITCS Admin
Welcome..