I have in production SQL Server 2005 and in Development SQL Server 2008 Database.
I would like to detach database from production create tables, insert data etc. and then attach it back.
How make it compatible after I make some changes in SQL server 2008?
What is the right way to do it?
There is no way to do this.
The only way I know to move a database from MSSQL2008 to 2005 is to script the tables.
Once the new tables are created in 2005, you can transfer the data either by scripting it (no fun) or by the data transfer wizard.
Changes to tables and data (for lookup tables) should be scripted and in source control like any other code. Then you run the scripts for the changes you are promoting to prod. This way other dev changes which are not ready to go to prod can be held back from being sent to prod.
I also do not recommend that you have a development database in a differnt version of SQL Server unless what you are testing to see if anything needs to be changed in preparation of moving to 2008. Otherwise, it is highly likely that bad code will be written that the prodcution database cannot handle becasue it is the wrong version and you will not find this out until you send the change to production.
Related
I want to migrate my all databases from SQL Server 2012 to SQL Server 2014. Is there any way to do all in one short instead of one by one?
you can simply do in-place upgrade in the same server, instead of migration, if possible. It will one-shot operation.
You can do side by side migration, by taking backup in source environment(MSSQL 2012) and restore databases in target environment(MSSQL 2014).
This is a very important operation and many things have to be planned. You have to have migration plan for this.
You can use upgrade advisor tool for this. It will tell you whether everything is fine on your instance for initial analysis: https://msdn.microsoft.com/en-us/library/dn236457(v=sql.120).aspx
Also, read below articles.
https://thomaslarock.com/2014/06/upgrading-to-sql-server-2014-a-dozen-things-to-check/
https://blogs.technet.microsoft.com/meamcs/2013/12/14/what-to-consider-when-creating-sql-server-database-migration-plan/
There are lots of guides available online. Just search internet. you will find many guides.
You can do it in 2 ways:
1.Create a backup of your database and restore it in new server.From Management Studio you can Right-click on your database then select Tasks -> Back up.
2.Generate script, create the database in the new server and run the script.From Management Studio you can Right-click on your database then select Tasks -> Generate Scripts.
I have a database deployed on a testing machine and a production machine. There is some data (columns of a table) in the testing database that I would like to copy over to production.
When I try to restore a backup onto the production box I get the following error:
System.Data.SqlClient.SqlError: The database was backed up on a server running version 10.50.1600. That version is incompatible with this server, which is running version 10.00.4000. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.Smo)
Is there an alternate way to get the data into the table?
This answer ONLY if you need the data (from here: http://sqlserverlearner.com/tag/the-database-was-backed-up-on-a-server-running-version-10-50-1600-that-version-is-incompatible-with-this-server):
Script the object you want (table and data) under tasks, generate scripts, select the object, and make sure to include all the data (possibly the schema as well). Take this to a new query window and save the SQL file, then execute it on your other server.
You could
Generate INSERT statements for the data in question
Create a linked server from the test to the other server and run sql statements against that
Upgrade the target server to 2008 R2 (this is not something to take lightly)
You should keep your environments at the same version / rev. SQL Server restores are not backward compatible.
Use generate scripts with data, you can select the version of MSSQL. Then run the outputted SQL on the server you want it.
Ideally you'd upgrade your production server to match your test environment, otherwise your tests may not always be representative.
If they are different versions though, you can't restore a database to an older version of SQL server, you should either use the generate scripts command to create the new table and insert the data, or use a tool like SQL compare/Data Compare from RedGate which will do all of this for you.
This is the problem with the sqlserver version mismatch while restoring the database. It means It couldn't possible to restore the database server 2008 to 2005. It wouldn't support higher version to lowerr version.
The following options are available,
You can link the servers and move the table from one server to other server
Generate the sql script and execute in the target database
Use the below URL to generate the insert script and execute generated script into target server.
http://www.codeproject.com/Articles/5598/Generating-INSERT-statements-in-SQL-Server
you can use redgate toolbelt tool kit to sync data between different version of sql server or sql server to sql azure or sql azure to sql server database . it is very very easy to use .
A client has no option but to migrate from sql server 2000 to 2008 within the next few days. Tests have shown unacceptable performance degradation in vital functionality in 2005 but not in 2008. Good stuff however, the application uses DTS to import external market data into the database and DTS is no longer supported by 2008.
Until such time as the function can be rewritten, I'm thinking the import could be done in an instance of 2005 and the data (from one table) subsequently uploaded into 2008.
(a) is there an alternative option?
(b) if not, is there a simple way of achieving the data upload from 2005 to 2008?
Any assistance/advice gratefully received.
I might be misunderstanding what you need to do, but one thing you can do to move a database from from 2005 to 2008 is to just back up the database on the 2005 instance to a .bak file: right-click on the database in the Object Explorer in Management Studio (or whatever it's called in your version of SQL Server!), and do Tasks -> Backup database, and save it somewhere you can see from both instances. Then go to the 2008 instance do "Tasks -> Restore database" in the 2008 instance and the restored copy of the database should just work in 2008.
I think you might have trouble going the other way though, with this method.
You could use an SSIS package to execute the DTS packge, and AFAIK you can execute DTS 32 bit in SQL 2008 (MS link). The other option would be to run the database in a compatibility mode which ~may~ avoid the performance issues you're seeing. All in all, you might be better off rewriting your DTS with SSIS. The concepts similar and you shouldn't have too much trouble recreating it with SSIS.
I would like to copy a database (tables, it’s data, stored procs & views) from SQL Server 2008 database to SQL Server Express. Is it possible? If so, would you please let me know how to do it? When I tried, it is giving some error.
Please note that I have only few records in SQL Server 2008 database tables.
Thanks and Regards..
Shruthi Keerthi..
The quickest way is to "detach" the source database from its server, copy the (2) files to a new name/location and (re)attach each database to the appropriate server.
Attach/detach is available as a command or via the SQL Visual Studio.
You can create a backup of the database and them restore that backup into the Express instance.
Another option, since you said you didn't have very many records in the DB, is to generate the SQL statements (right click on the database --> tasks -> generate scripts) and then run that on the Express instance. Then just copy over the tuples you want.
I prefer to use Backup/Restore when moving a database from one server to another. As long as your SQL Server and SQL Express are the same version, or the one you are moving to is newer than the one you are moving from (SQL 2005 to SQL Express 2008), it should work without a hitch.
If copying the entire database, I usually find it easiest to stop the source service, copy the *.mdf file to the appropriate new data directory, and just mount the MDF in the new service. As long as there aren't any changes in the setup (like FILESHARE), then this is the easiest way to clone a database.
And yes, this is possible. I just did this earlier today.
You could also try using the Microsoft Database Publishing Wizard.
It's simple to use and will create a SQL script that you can run to rebuild tables (including data), stored procs, views, etc...
You can download it here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en
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.