July 18, 2009 at 6:45 am
actually i need to import tables and stored procedures from one database to another new database using an sql query. how to do it? please help me out.
July 18, 2009 at 7:51 am
Hi there,
check out Server Generate SQL Server Scripts Wizard — http://msdn.microsoft.com/en-us/library/ms181421.aspx
July 18, 2009 at 10:01 am
You can use three part naming, database.schema.table to reference the other database. The write an insert select statement.
If you try and have issues, we can help, but we don't do work for you. Make an attempt.
July 18, 2009 at 10:00 pm
Steve Jones - Editor (7/18/2009)
You can use three part naming, database.schema.table to reference the other database. The write an insert select statement.If you try and have issues, we can help, but we don't do work for you. Make an attempt.
i have database named DBOIL
under this i hv stored procedures named Insert_IndentRaising
my new database name is DBOIL0910
when im tried as you suggested..,
insert select DBOIL.dbo.Insert_IndentRaising
it gives error..
how to use insert select syntax..?
July 19, 2009 at 12:55 am
karthimca07 (7/18/2009)[hr
i have database named DBOIL
under this i hv stored procedures named Insert_IndentRaising
my new database name is DBOIL0910
when im tried as you suggested..,
insert select DBOIL.dbo.Insert_IndentRaising
it gives error..
how to use insert select syntax..?
That will only work for tables not for SPs. You can script out the SPs on the source database and apply the script on the target database.
Also, the insert statement you wrote is syntactically incorrect.
correct syntax is
Insert into mytable from db2.owner2.table
. This will create a table myTable in your database similar to the table "table" in db2 and will move all the data.
July 19, 2009 at 8:47 am
ps (7/19/2009)
karthimca07 (7/18/2009)[hr
i have database named DBOIL
under this i hv stored procedures named Insert_IndentRaising
my new database name is DBOIL0910
when im tried as you suggested..,
insert select DBOIL.dbo.Insert_IndentRaising
it gives error..
how to use insert select syntax..?
That will only work for tables not for SPs. You can script out the SPs on the source database and apply the script on the target database.
Also, the insert statement you wrote is syntactically incorrect.
correct syntax is
Insert into mytable from db2.owner2.table
. This will create a table myTable in your database similar to the table "table" in db2 and will move all the data.
i script out all stored procedures into an single file.
then i redd the entire content of the file in string
and executed from vb.net.
it shows syntax error
incorrect syntax near "Go"
July 19, 2009 at 10:53 am
The script is a T-SQL script. You need to execute it in SSMS.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply