Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to generate insert data script from #temp tables?

In DB I have #temp tables with data and I need to generate insert Scripts (for all data).

How it can be done ? I right clicked on tempDB and selected > Tasks > Generate Scripts but I can't select #temp tables to generate script (they are not avaialble to select).

how I can geneate Insert script from #temp tables I m using SQL Server 2008 R2.

like image 231
user576510 Avatar asked Apr 16 '15 05:04

user576510


People also ask

How to generate an insert script from the data editor?

There are two options for generating an insert script from the data editor —. 1. Select ‘Script’ option to generate the script to another tab. 2. Select ‘Script to File’ option to generate the script to a file. And once you click on ‘Script’ or ‘Script to File’ button, the Insert Scripts will be generated and available to us.

How to generate insert scripts in SQL Server management studio?

SQL Server Management Studio provides a ‘Generate and Publish Script‘ Wizard which helps us to generate the scripts for table schema or data. This is one of the nicest feature of SSMS and is generally used for generating the insert scripts. Right Click on the Database and go to Tasks -> Generate Scripts

How to generate insert scripts in Microsoft Excel 2016?

Right Click on the required table and select ‘View Data’. 1. Select ‘Script’ option to generate the script to another tab. 2. Select ‘Script to File’ option to generate the script to a file. And once you click on ‘Script’ or ‘Script to File’ button, the Insert Scripts will be generated and available to us. It is as simple as that!

How do I create a script for a table in SQL?

Right Click on the Database and go to Tasks -> Generate Scripts Be default, this wizard generates the scripts for the table schema only. If we need to generate Insert scripts for the data, we will need to go to the ‘Advanced Scripting Options‘ and change the ‘Types of data to script‘ from ‘Schema only’ to ‘Data only’.


1 Answers

You can insert your query results into sql table (temporary table , it will be created automatically ):

SELECT * INTO myTempTable FROM (query results) 

e.g : SELECT * INTO myTempTable FROM user where condition

A table named myTempTable will be created inside schema dbo Then click on database click :

Tasks > Generate Scripts

and you choose the table myTempTable

like image 166
Zied R. Avatar answered Sep 28 '22 18:09

Zied R.