none
SQL Query RRS feed

  • 問題

  •  

    Dear Expert.

     

    I'm writing the Report in SQL Server. 

    If i need to refer the data on different DB that located on different Server. How can i do it?

    Can you provide any sample for me?

     

    Thanks

     

    2008年4月15日 上午 11:18

解答

  •  Deepblue10111 寫信:

     

    Dear Expert.

     

    I'm writing the Report in SQL Server. 

    If i need to refer the data on different DB that located on different Server. How can i do it?

    Can you provide any sample for me?

     

    Thanks

     

     

    Are you writing Mobile App / Win App / Web App from .NET? Or you are building the report by using Reporting Service?

    You may use 2 DataSet from Reporting Service, or use 1 DataSet with 2 DataTable from 2 Connections from .NET.

    2008年4月16日 上午 01:53

所有回覆

  • Hi

    <<

    If i need to refer the data on different DB that located on different Server. How can i do it?

    Can you provide any sample for me?>>


    I think you can try to create a linked server on your current database server.
    then You should be able to access data on the other database server

    On SQL 2000) What i normally do is to use Enterprise manager and click on the Security folder. Then Right click on "Linked Server" and Select "New Linked Server" Then you can fill in the details like the Linked Server name, Production name, Catalog...etc. On the Security Tab you need to choose how do you login to the Linked Server.

    On SQL 2005) I used SQL Server Management Studio and Click on the Server Object folder. and do the similar thing as above to create the linked server.

    If you would like to do it on TSQL command you can read the link below.
    http://msdn2.microsoft.com/en-us/library/ms190479.aspx

    If you want to access the data on the linked server.

    You can do a query as normal. but put the linked server name at the 1st part of your query.

    E.g. I have a linked server called [LinkedServerTest]
    A Database Called [Examples]
    Table called [Customer]

    You can use a select statement like:
    SELECT *
    FROM [LinkedServerTest].[Examples].dbo.Customer

    To retrieve the data.

    Hope this can help. Please let me know if I mis-understood your topic.

    Many thanks

    Chi
    2008年4月15日 上午 11:50
  •  Deepblue10111 寫信:

     

    Dear Expert.

     

    I'm writing the Report in SQL Server. 

    If i need to refer the data on different DB that located on different Server. How can i do it?

    Can you provide any sample for me?

     

    Thanks

     

     

    Are you writing Mobile App / Win App / Web App from .NET? Or you are building the report by using Reporting Service?

    You may use 2 DataSet from Reporting Service, or use 1 DataSet with 2 DataTable from 2 Connections from .NET.

    2008年4月16日 上午 01:53