How to Export Whole Database with Data Inside - sql

I can Generate Create Scripts of my database in MS Sql Server Management Studio. But I need to move the database to a shared server with all the data in it.
Since I don't have full admin rights, I can not backup/restore .bak files or attach there. Is there any way to generate "Insert" queries which insert all of the data when I run them after create queries.

Yes. Here's how to do it:
Open up SSMS
Right-click on your database
Tasks -> Generate Scripts...
Choose the objects you want to script out (it sounds like you want the whole DB)
Under Set Scripting Options click the Advanced button
For the item Types of data to script, select Schema and data

Related

Option to generate DDL in Azure SQL DW

Couldn't find an option to generate DDLs from SSMS in Azure SQL DW(Synapse).
Is there any alternative approach to get the same using tools like sqlcmd or some other tool?
From the Object Explorer, you right click on an individual object.
If you want to script the entire database, you can right-click on the database name and select Generate scripts... which starts the script wizard.

SQL to copy database and data on to a dev machine

I'm looking for a way to duplicate an existing database, tables and data onto a different development machine. Using SQL server 2008;
I have several tools i usually use for duplicating databases or i just restore a database dump, but i cannot use any of these. I have no direct access to the database machine i can logon via SQL enterprise manager and run queries stored procedures etc. But i have no access to the file system so i'm unable to create or copy a database dump. I cannot install or connect any tools to the database as i have to logon via a remote desktop. I also only have access to copy text files on and off the network.
I would like to run a script to generate a script to create the tables, views stored procedures etc and a script to populate the tables with some data.
I need to create a test environment so i can run tests and develop new features without affecting the live DB.
Assuming you have access to the database via SSMS, this is the approach I would take, though it could be time consuming:
Right click on the Database
Hover 'Tasks'
Hover 'Generate Scripts' and complete the process, it's self explanatory.
And from there it will generate a script for the Database architecture. This is the quick portion.
Next download Visual Studio and get the Integration Services add on. Using SSIS packages you'll be able to select all data from each source table/database and then insert the data into the destination table/database. Hope this helps you get on the right path.

How do I script out a full database to a series of creation scripts?

I'm looking for a way to script out an entire SQL Server 2015 database to write table creation scripts, stored procedure scripts, triggers, etc etc to a folder so I can set a baseline for a TFS repository solution. Apart from manually exporting each script one by one, is there a way to do a bulk export?
Obviously I'm not talking about data here, I'm talking strictly about exporting creation SQL file scripts to a folder for a single database.
Please try with SQL Server Management Studio.
To open the Generate and Publish Scripts Wizard. In Object Explorer, expand Databases, right-click a database, point to Tasks, and then click Generate Scripts. Follow the steps in the wizard to script the database objects. On the Choose Objects page, select the objects to be included in the script.
https://technet.microsoft.com/en-us/library/ms178078(v=sql.105).aspx
you can generate sql scripts in ssms by following steps:
Right Click on the Database
Go to task and then Click on "Generate Scripts..."
follow the wizard steps to create scripts

save the whole database to a query in sql server 2008

I'm trying to save the whole database to a query in sql server 2008. I have experience with mysql and phpmyadmin, and over there I used to have a simple button to save the database, including constraints and basically everything, to a simple query.
that query basically recreates the database i created just as it was. I think you guys understand what I mean.
is there such an option in ms sql server? thank you in advance.
You can generate scripts to recreate the database structure in SSMS:
Right-click a database, choose Tasks > Generate Scripts... and go through the wizard.
You do not get insert scripts for all the data by default, you need to choose that in the Advanced options in the wizard, Types of data to script choose Schema and data/Data only/Schema only`
For SQL Server, I generally go with a backup/restore point of view. You can backup your entire database to a file, and then choose to restore that database (To another name as I often use for recreating new test databases).
I don't know about creating a query out of the database, but the effect of both seems to be the same result.

How do I back up SQL 2008 tables & stored procedures?

Last night I got completely hosed by a worm from Dilbert.com (so be careful there). It is invasive enough where I am going to do a complete system restore. The only thing I need to save on the pc is a database (consisting of just tables & stored procs) in SQL 2008. How can I export them so that, once I restore, I can easily import them again. I thought about doing Access, but that is never completely clean (data types get changed and such).
You should just be able to back up the database from within SQL Server Management Studio. Right-click on the database in the Object Explorer and use the context menu to begin a backup operation.
In addition to the backup operation, which restores everything, you can also use the Generate Scripts option in SQL Server Management Studio to create a text dump of all the tables, keys, stored procedures, users, and so on. This option is available by selecting your database (left click once), right click to get the option menu, then choose "Tasks" (which opens a new submenu) and then "Generate Scripts...". Note that the Generate Scripts wizard is NOT the came as the "Script Database As" option. The "Script Database As" option is very limited, and won't give you many of the database entities you need for a complete restore of the schema.
Alternatively since you are going to take the machine down anyway, just detach the database. Then you can copy the file to an external hard drive or another machine.