General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 2nd, 2004, 08:45 PM
Brick1235 Brick1235 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 31 Brick1235 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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

Reply With Quote
  #2  
Old March 2nd, 2004, 10:24 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
If the DB is on another server, then you need to change your connection settings, not the query.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old March 3rd, 2004, 12:00 AM
Brick1235 Brick1235 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 31 Brick1235 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
But what if it is a Stored Procedure? Can it be done?



NHK

Reply With Quote
  #4  
Old March 3rd, 2004, 12:38 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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.

Reply With Quote
  #5  
Old March 4th, 2004, 09:30 PM
Brick1235 Brick1235 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 31 Brick1235 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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

Reply With Quote
  #6  
Old March 4th, 2004, 10:05 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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

Reply With Quote
  #7  
Old March 7th, 2004, 06:54 PM
Brick1235 Brick1235 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 31 Brick1235 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Thanks man ... your article is great.

Oh yeah the statement =

<ServerName>.<DatabaseName>.dbo.<TableName>.<ColumnName>

doesn't work.

NHK

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > SQL Database to another Database.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway