468,457 Members | 1,746 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,457 developers. It's quick & easy.

Connect MSSQL remotely by Query Analyzer

Hi,

I wish to know the syntax for connecting to a remote MSSQL 2000 DB Server via Query Analyzer.

Actually my requirement is to use the connection string to connect to the remote server, execute a SQL Statement on the remote server & save the resultset in a table on my local machine.

Can anybody helpme ?
Oct 17 '07 #1
2 3033
iburyak
1,017 Expert 512MB
Did you try something like this?



Expand|Select|Wrap|Line Numbers
  1. Insert into some_table
  2. SELECT a.*
  3. FROM OPENROWSET('MSDASQL',
  4.    'DRIVER={SQL Server};SERVER=seattle1;UID=sa;PWD=MyPass',
  5.    pubs.dbo.authors) AS a
  6. ORDER BY a.au_lname, a.au_fname

or this

Expand|Select|Wrap|Line Numbers
  1. insert into some_table
  2. SELECT   *
  3. FROM      OPENDATASOURCE(
  4.          'SQLOLEDB',
  5.          'Data Source=ServerName;User ID=MyUID;Password=MyPass'
  6.          ).Northwind.dbo.Categories
Oct 17 '07 #2
Thanks a lot Dear.

Your code was exactly what I needed. I wasn't able to understand how to create a connection which your code helped me to.

Thank again.

Ankit Mathur


Did you try something like this?



Expand|Select|Wrap|Line Numbers
  1. Insert into some_table
  2. SELECT a.*
  3. FROM OPENROWSET('MSDASQL',
  4. 'DRIVER={SQL Server};SERVER=seattle1;UID=sa;PWD=MyPass',
  5. pubs.dbo.authors) AS a
  6. ORDER BY a.au_lname, a.au_fname

or this

Expand|Select|Wrap|Line Numbers
  1. insert into some_table
  2. SELECT *
  3. FROM OPENDATASOURCE(
  4. 'SQLOLEDB',
  5. 'Data Source=ServerName;User ID=MyUID;Password=MyPass'
  6. ).Northwind.dbo.Categories
Oct 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by polinaskulski | last post: by
4 posts views Thread by kenneth.osenbroch | last post: by
4 posts views Thread by D | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.