May 19, 2010 at 6:52 am
I have 2 DB named lrb and lrc, now i have a store procedure in db "lrc", i have to write some query in this stored procedure(lrc) which gets data from 'lrb' db, how to do that?
Thanks in advance
May 19, 2010 at 6:54 am
If both the databases are on the same server (SQL Instance) then use 3 part notation as
SELECT COL1,COL2,COL3 FROM LRB.dbo.Table
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
May 19, 2010 at 7:00 am
Thanks, very much it worked.. and also if it is in different server, do i need to add some more param?
May 19, 2010 at 7:11 am
pattamuthu (5/19/2010)
Thanks, very much it worked.. and also if it is in different server, do i need to add some more param?
If it is a different server you need to add a linked server and user wither Open Query or use 4 part notation
Something like this LinkedserverName.DBName.Schema.Object
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
May 19, 2010 at 7:17 am
Thank you very much
May 19, 2010 at 7:26 am
You are welcome!
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
May 19, 2010 at 9:16 am
I am sorry, QUERY works, but i could make the same in stored procedure.
i have PROCEDURE in lrc DB, how do i call lrb DB, in lrc procedure.
Thanks in advance
May 19, 2010 at 9:26 am
You need to use EXEC dbname.schema.Sprocname from your 1st database.
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
May 19, 2010 at 9:42 am
I need to write a stored procedure in LRB and i need to call(exec) in the LRC Stored procedure. IS that correct?
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply