|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OpenrowSet querrywhat 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') 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. 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') > 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') Fantastic! I could see that your connection string was incomplete.
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') > |
|||||||||||||||||||||||