SolvedPrivate

Create table with data

Posted on 2013-11-20
9
39 Views
Last Modified: 2016-02-11
Is there a way to generate a script on a table that will
Create the table if not exists
Insert the current data
0
Comment
Question by:lrbrister
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 39662652
From Management Studio

Right-click the table, from the menu "Script Table as - > CREATE to->"
This will recreate the table
0
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 39662663
Better yet, select the database, right-click, Tasks->Generate Scripts and you should be able to do anything.
0
 

Author Comment

by:lrbrister
ID: 39662707
SStory,
 That doesn't get me the data to insert as well
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 25

Expert Comment

by:SStory
ID: 39662731
When it gets to Set Scripting Options, click the Advanced button and change
Types of data to script to "Schema and data"

You do actually have to look around in these tools to get them to do what you need, but this should do it.
0
 

Author Closing Comment

by:lrbrister
ID: 39662737
In the Generate Scripts Advanced Tag was the ability to generate schema as well as data.

Thanks
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39662739
>Insert the current data
None that I'm aware of that will save it as a script.  Have fun with that.

The work-around that is easiest to pull off would be to export the table data as a .csv, save it with the script, then the target db will have to...
Execute the CREATE TABLE script
Do an SSIS / Import wizard to connect to the .csv as the source, the created table as the target, and execute.
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 39662743
If the table doesn't exist, what "current data" are you talking about?

If you mean copying data from one db to another using the same table name, then, yes, there are ways to do that.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39662763
>Advanced tab, Types of data to script ... Schema and Data
Learn something new every day.  Now that's handy..
0
 

Author Comment

by:lrbrister
ID: 39662775
Yes it is
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My client sends a request to me that they want me to load data, which will be returned by Web Service APIs, and do some transformation before importing to database. In this article, I will provide an approach to load data with Web Service Task and X…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question