Mark B. – tech

SQL Server : OPENDATASOURCE

OPENDATASOURCE : Provides ad hoc connection information as part of a four-part object name without using a linked server name.

Syntax

OPENDATASOURCE ( provider_name, init_string )

link : http://msdn.microsoft.com/en-us/library/ms179856.aspx

Examples

A.     Executing a SELECT pass-through query
SELECT * FROM
OPENDATASOURCE(‘MSDAORA’,‘Data Source=ORCLDB;uid=usr;password=pwd’).joe.titles

B.     Executing an UPDATE pass-through query
UPDATE OPENDATASOURCE(‘MSDAORA’,‘Data Source=ORCLDB;uid=usr;password=pwd’).joe.titles
SET name = 'ADifferentName'
WHERE id = 101'

 C.      Executing an INSERT pass-through query
INSERT INTO
OPENDATASOURCE(‘MSDAORA’,‘Data Source=ORCLDB;uid=usr;password=pwd’).joe.titles
(Name) VALUES ('NewTitle')

 D.     Executing a DELETE pass-through query
DELETE OPENDATASOURCE(‘MSDAORA’,‘Data Source=ORCLDB;uid=usr;password=pwd’).joe.titles
WHERE name = 'NewTitle'
Advertisements
This entry was published on May 30, 2011 at 9:40 am and is filed under IT - Tutorial. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: