Home All Groups Group Topic Archive Search About
Author
14 Sep 2006 5:55 PM
SQL Ken
what is wrong with my code here?
I need to query from a remote sql server.

thanks


SELECT *
FROM
OPENROWSET('SQLOLEDB',
            '192.132.88.30';
             'loginName';'Password',
         'SELECT *
          FROM MyDataBase.dbo.Mytable')

Author
14 Sep 2006 6:07 PM
Warren Brunk
Here is a books online sample
OPENROWSET
(
'SQLOLEDB.1',
'Provider=SQLOLEDB.1;Username=USERNAME;Password=PASSWORD;Initial
Catalog=AdventureWorksDW;Data Source=192.132.88.30',
'SELECT TOP 1000 * FROM vTargetMail'
)Two things are wrong.
1. you dont need the outer select
2. Your IP Address Should be a connection string to the database as opposed
to just an IP address.


--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/


Show quote
"SQL Ken" <SQL***@gmail.com> wrote in message
news:1158256538.287147.39510@p79g2000cwp.googlegroups.com...
>
> what is wrong with my code here?
> I need to query from a remote sql server.
>
> thanks
>
>
> SELECT *
> FROM
> OPENROWSET('SQLOLEDB',
>            '192.132.88.30';
>             'loginName';'Password',
>         'SELECT *
>          FROM MyDataBase.dbo.Mytable')
>
Author
14 Sep 2006 6:23 PM
SQL Ken
Found a correct(working) sample

SELECT * FROM
       OPENROWSET('MSDASQL',
      'DRIVER{SQLServer};
                  SERVER=192.125.88.10;UID=login;PWD=password',

                  'SELECT *
      FROM MyDB.dbo.Mytable')
Author
14 Sep 2006 6:28 PM
Warren Brunk
Fantastic!  I could see that your connection string was incomplete.

--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/


Show quote
"SQL Ken" <SQL***@gmail.com> wrote in message
news:1158258203.955347.324470@b28g2000cwb.googlegroups.com...
> Found a correct(working) sample
>
> SELECT * FROM
>    OPENROWSET('MSDASQL',
>   'DRIVER{SQLServer};
>                  SERVER=192.125.88.10;UID=login;PWD=password',
>
>                  'SELECT *
>   FROM MyDB.dbo.Mytable')
>

AddThis Social Bookmark Button