|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL Database to another Database.
Uhmm not many ppl post here.
Well I will contribute abit more nonsense and make ppl head go exploding thinking what did i just ask. Ok I have this SQL statement use in my office. It jumps from one Database Table to another database table. This statement work for my office now/currently. But when I think hard yesterday (WOW I could think hard), what if the Databse is on another server? SELECT StaffInfo.dbo.[Staff Details].INITIAL, StaffInfo.dbo.[Staff Details].NAME, Training.Continuing, Training.Remarks FROM Training LEFT OUTER JOIN StaffInfo.dbo.[Staff Details] ON Training.S_code = StaffInfo.dbo.[Staff Details].S_CODE LEFT OUTER JOIN Seminar ON Training.Sem_id = Seminar.id WHERE Seminar.Training = '<Something here>' And another question I wish to ask is, whether the above SQL statement is actually a good practice? Thank you for all of you. NHK |
|
#2
|
||||
|
||||
|
If the DB is on another server, then you need to change your connection settings, not the query.
|
|
#3
|
|||
|
|||
|
But what if it is a Stored Procedure? Can it be done?
NHK |
|
#4
|
||||
|
||||
|
I'm not following. You asked about running a query (or SP) on another server. Obviously, the SP would have to be in the RDBMS that you are performing the action on. Alternativaly, you can just use inline dynamic SQL, if you don't have access to the server.
|
|
#5
|
|||
|
|||
|
oh...
So the code would be like... uhmm If my DBS is all link I should put like this issit? <ServerName>.<DatabaseName>.<TableName>.<ColumnName> issit? NHK |
|
#6
|
||||
|
||||
|
Yeah - I think that would work in theory. I just had a quick look on google, but it's a difficult thing to query on. Give it a shot and see how you go - I'd be interested in the results.
From memory, I think you need two dots between DatabaseName and TableName, and you'll prolly need to do that for server to db also... can't remember exactly. EDIT: just found these links - they look pretty good - though are SQLServer specific: http://www.schemamania.org/jkl/book...tml/8_qd_12.htm http://www.schemamania.org/jkl/book...1_server_10.htm |
|
#7
|
|||
|
|||
|
Thanks man ... your article is great.
Oh yeah the statement = <ServerName>.<DatabaseName>.dbo.<TableName>.<ColumnName> doesn't work. NHK |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > SQL Database to another Database. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|