Sql – how to transfer stored procedures between SQL Server 2005 databases

deploymentsqlsql-server-2005

I'm creating web site on local computer. i'm using SQL Server 2005 management studio. I need to copy all data to destination server. Destination server is SQL Server 2005. My problem is

  1. when i using import/Export data for management studio, this only copy tables.
  2. when i using backup and restore, tables and stored procedure shows like this

myuser.aspnet_application

myuser.aspnet_Membership … etc.
I need to create like this

dbo.aspnet_application

dbo.aspnet_Membership

How to copy stored procedures and views to destination server?

Best Answer

In SQL Server Management Studio navigate to your database.

Right click it and select "Tasks" -> "Generate Scripts"
"Next"
Select your database from the list
"Next" Select "Stored Procedures" "Next"
"Select All" "Next"
"Script to new Query Window" "Next"
"Finish"

Give it a while. Then when complete, at the very top of the script put "use (yourdatabase)"

Execute the use statement.
Execute the whole script.