How to batch database modifications from SQL Server Management Studio - sql-server

I'm struggling to figure out how to batch modifications to our databases in SQL Server Management Studio. We'll perform actions like editing columns, creating tables, renaming tables, etc. that we need to perform on all of our environments - but not until we're ready to push the application. I'm trying to use the SQL profiler to grab the SQL but this seems horribly inefficient.
Is there a solution built into the application that will track such changes for me?

Looks like I found my answer: http://www.mssqltips.com/sqlservertip/1723/auto-generate-change-scripts-in-sql-server-management-studio-ssms-for-tables/

you can easily create scripts using the osql utility if you are on a version lower than SqlServer 2005.
From sql server 2005 onwards we use sqlcmd

Related

Can't find Microsoft SQL Server even if it is installed?

Regarding the following images, I have obviously installed the Microsoft SQL Server, but I can't find the exe-file or anything named Microsoft SQL Server in the start menu.
Anyone who knows what to do to solve this, or do I need to install something more?
SQL Server runs as a service. You can start and stop it from windows services. SSMS is a gui tool for managing ddl (creating and altering tables and index's for example) and dml (writing queries to inquire, update or add data to databases).SSMS comes free with every edition of SQL server - perhaps you didn't tick a box when installing? You can also do this stuff the old fashioned way using sqlcmd from command line(DBAs love this for some reason) but for us mortals SSMS is much less of a struggle. As an aside there are other guis such as Toad (expensive) and Heidisql (free) amongst others which will do the job.
Looks like you have the engine. What you've got to do now is install SQL Server Management Studio: https://msdn.microsoft.com/hr-hr/library/mt238290.aspx
Looks like you have the various SQL Server components that are installed by Visual Studio (recent version) or SQL Server Data Tools (as used by VS).

Transfer a SQL Server database without data

I'm trying to move a database from a server in one data centre to a server in my local data centre. The pipe between the two is very slow. Luckily I only need to transfer the schema, not the data. Is there an easy way in SQL Server to transfer just the schema of a database without the data?
Go to Management Studio's Object Explorer and select Tasks > Generate Scripts ...
Then step through the wizard, select those objects you need, select whether to script out to a single file or to a file per table / view - whatever you need.
Then transfer the .sql script(s) to the target system, launch Management Studio there, run the scripts - done!
I would use the SQL Server Publishing Wizard for this.
One approach would be to generate scripts of your existing database (in SSMS right-click the database, then Tasks, then Generate Scripts ...). Go through the wizard to generate your script file(s). Then run the script(s) on the target system.
There are a variety of third party tools which can do this for you pretty easily, such as Red Gate's SQL Compare and DB Ghost. ApexSQL has a free, community version of ApexSQL Diff. Devart has a dbForge Studio Express for SQL Server which has schema compare capabilities.
There are also several other questions on Stack Overflow which provide some ideas:
Free Tool to compare Sql Server tables [closed]
Best tool for auto-generating SQL change scripts for SQL Server [closed]
Anyone know of any good Database Diff tools? [duplicate]
Microsoft's Visual Studio can even do schema comparisons now.
But you should be able to script the entire database using SQL Server Management Studio (SSMS) as Marc S's answer now describes. This option was also proposed by Chris Brandsma in his answer to Script entire database SQL-Server.

Can SQL Server synchronise a live database and a create script to make an update script?

We are currently updating our SQL Server database create and update scripts by hand, and I'm looking for a better way.
I've worked extensively with MySQL Workbench before, and it has functionality to update a database creation script to match a live database, and in the process also produce an update script.
Is there similar functionality available in SQL Server? If so, can you please provide references to it?
If you're using Visual Studio, the answer is SQL Server Data Tools (SSDT). It comes with SQL Schema Compare functionality. Check it out here: http://msdn.microsoft.com/en-us/data/tools.aspx
SSDT can also do a lot of other stuff, like automated database testing, automated build and deployment of databases, etc.
There are also 3rd party alternatives, such as Red Gate's SQL Compare: http://www.red-gate.com/products/sql-development/sql-compare/

SQL data comparison tool for SQL Server Compact

Does anyone know of a tool similiar to RedGate's SQL Data Compare that works with Microsoft SQL Server Compact 3.5?
For me the following process worked:
Install SQL Server Compact Toolbox extension.
Run the "Script database schema and data" command on both databases
Use a diff tool on generated files to see the changes.
In the end I solved this problem by Exporting my 2 SQL Server Compact Databases to SQL Server Express 2005 (although 2008 would work) using Data Port Console.
I then compared them using Red Gate SQL Data Compare.
This solution works just fine for me.
Not sure, but you could also have a look at the Apex SQL tools - Apex SQL Diff and Apex SQL DataDiff. There website is here. They don't specifically mention SQL Server Compact - but I'm sure you could inquire with them.
Red-Gate and Apex are my #1 choices for any kind of SQL tools :-)
Marc
Have you tried SQL Compare from starinix? They say it supports SQL Server (All Editions) so that may include compact edition.
This software does work as I have used it (for Yukon). It's also freeware which saves worrying about licensing.

Easiest way to copy an entire SQL server Database from a server to local SQL Express

I need to copy an entire database from a SQL Server 2005 on my server over to my local SQL Express in order to run my application for a presentation. What is the fastest/easiest way to get this done?
EDIT: I have very limited access to my server so I don't think I can access the backup file that I could create so that is out.
If the database is not too big, you could use the Database Publishing Wizard.
This is a free tool from Microsoft which creates a complete SQL script of a database for you (not only the tables and stuff, but all data as well).
You can install the tool on your machine, connect to a remote server and let the tool create the script directly on your machine.
You can download the Database Publishing Wizard here.
Apparently the link above doesn't work anymore in 2019.
That's probably because in newer versions of SQL Server Management Studio, the functionality of the Database Publishing Wizard is included out-of-the-box, so there's no need to install it separately.
It's now called the Generate and Publish Scripts Wizard, but it does exactly the same.
You can right click the database -> Tasks -> Generate scripts. Here you can select one, multiple, or all objects. Then in the 'Set Scripting Options' step of the wizard, click Advanced. In here set the property 'Types of Data to script; to Schema and Data.
Having done these steps, make sure you publish to a file. Because only file can handle large amounts of data.
Now you should have all your objects, tables, and data scripted. Now start running the scripts and viola!
Back up the database on the server and then restore it locally in SQL Express.
EDIT: If this is part of your work, surely you can get someone in networks to get you a backup..?
If you can login to both servers (the Express and the 05 Server) using SQL Server Management Studio then you can do a DB Restore from one database to the other. No need for backup files at all.
You can use SSIS's database copy wizard, but it's not quick at all. Is there a DBA there that you can ask for the backup file? That will probably turn out to be the fastest way.
Depending which versions of SQL Server you are using, you might get some mileage out of the SQL Server Database Publishing Wizard from Microsoft. I've had mixed results with this tool in complex environments, but for most simple database scenarios it is a great tool.
An example of a scenario where I ran into difficulties was a DB with multiple distinct schemas, each with their own owner and extreme separation between the tables (don't ask...). As I said, though, most other scenarios have been fine.
Save your database as a sql script
EMS SQL Manager (for example) allows you to backup your database as a script in a .sql file. It is then possible to run this file against any other SQL server. Just update the first line of the script (CREATE DATABASE ....).
You can even fully parameter the script in order to include data from complete or filtered tables.

Resources