How to create a database using SQL Scripts? - sql-server

I have SQL script and I need to create a database in other server using this SQL scripts in SQL server 2016. Is it possible and can you explain me the steps to do it?

Right click database on the old server instance, Script Database as, then Create to, execute the script on the new server instance after changing the Connection

Related

duplicate a Database content into another database

I have a database that I want to duplicate into another database.
I'm using Sql Server 2012 Express Management Studio
I tried to make a backup of the database and tried to restore it as another database, but I couldn't
It happens that I was using LocalDB\v11.0, but I had to upgrade my sql server express to the version that accepts remote connections.
But now I have two servers, LocalDB\v11.0 and .\SQLEXPRESS, my database is in LocalDB and I want it in .\SQLEXPRESS
How can I do that?
Rafael
Though I haven't tried but this shouldn't be the case. AFAIK, LocalDB\v11.0 introduced in SQL Server 2012 and you can backup/restore between localdb and sqlexpress.
if that's not working then try posting the error/issue you are getting in this post.
Anyway, you can also script your database, schema and data and then run those script locally.
See this post here for the same ...
http://social.msdn.microsoft.com/Forums/en-US/b75bef7e-13f3-4658-8d43-9df12ab4c320/connecting-localdb-using-sql-server-management-studio-express
Once you are connected, you can view the DB objects and script them in SSMS; thereafter run those same script in your sqlexpress instance.

Sql Server 2000 create scheduled job to run stored procedure

Have a client that is using sql server 2000. I know tsql. I need to create a scheduled job that runs a script to create a report from and/or insert data into a seperate table. How do i setup a job to run a sql script? Can anyone point me to a guide on creating reports from these jobs. Thanks. Do i need to create dts packages?
Open SQL Server Enterprise Manager. Expand the Management node.
Right Click Job from the Sub Nodes and Select New Job from the context
Menu.
You can use THIS to create the jobs.
check out for Sql Server 2000 for creating the scheduled jobs
Just wanted to add the full tree path in SQL Server Enterprise manager. Jobs are nested under the SQL Server Agent node in SQL Server Enterprise manager.
Open SQL Server Enterprise Manager
Expand Microsoft Sql Servers
Expand SQL Server Group
Expand Local
Expand Management
Expand Sql Server Agent

Cannot Create Database Diagram In SQL Server 2005

I've got SQL Server Management Studio 2005 and I'm trying to create a database diagram for a DB I created. I created the DB on the local SQL server an when I try to create a new database diagram it doesn't let me. It just gives me the option:
"Working with SQL Server 2005 diagrams".
It does not give me any option to create a new database diagram. It is strange though as I also connected to another SQL Server 2005 instance on our internal network and I have the option to create database diagram on that server.
Any help is appreciated.
Cian
If I remember correctly, you need a certain privilege (db-owner?) to create diagrams.
Could that be the problem?

Problem with importing an mdf created with SQL Server Express 2008 into SQL Server 2005

The question is probably extremely easy to resolve, but I need to resolve it because I need to carry on with my project. I am using SQL Server Express 2008 at home, and I've been working on an ASP.NET MVC app that stores my DB in an mdf file in the project's folder. The problem is that the SQL Server in the Uni labs is SQL Server 2005, and when I try to open the mdf file with the VS Server Explorer,It says that the version of the mdf file is more than the server can accept.
The only option that comes to my mind is exporting the DB as an sql file, just like I've done it thousand times with phpmyadmin. the thing is that the SQL Management Studio Express is not the most usable tool in the world, and for some strange reason all the articles I could find in Google were irrelevant. Please, help.
It is not possible to attach database created on SQL Server 2008 to SQL Server 2005. The other direction is possible.
Your only option is to script the database and data and run the scripts on SQL 2005. If you have used any of new features of the SQL Server 2008, you will have to rewrite the scripts.
I haven't used it much, but right click on database -> Tasks... -> Generate Scripts... / Export Data... / Import Data... should do the job right.
Google "Database Publishing Wizard", it's a tool from Microsoft to script an entire database, both schema and data.
you can script your db and its data. then run it on the target server to create a new db that is compatible with 2005 version.
Tools like Red-Gate SQL Compare and SQL Data Compare can compare a live database to e.g. a backup file, so you could compare your SQL Server 2005 database against the SQL Server 2008 Express backup file, and move data that way.
Or you could possibly generate INSERT statements for your tables that have changed data using a tool like this one here or this one here. These can generate INSERT scripts for your tables, which you can take along and run on your SQL Server 2005 target system.

I can't use a database in SQL Azure

I am trying to use a Database in SQL Azure. I have installed SQL Server 2008. I can Login SQL Azure and can use master Database. But I can't use other Database and I can't see any things in my object explorer. It shows this error:
"USE statement is not supported to switch between databases. Use a new connection to connect to a different Database."
How can I use another database?
You cannot link to another database server from SQL Azure, whether that other database is SQL Server or SQL Azure.
I found the Solution for this problem . I install SQL Server 2008 R2. then every thing is ok...
You can first create only the database before running the whole script to create schemas & Tables.
Then manually change the database to the new DB that was created.
Run the rest of the script. Do not run Use <databasename>

Resources