This is a modified version of the original post found here. Below is the standard operations (SELECT, INSERT, UPDATE & DELETE) used in T-SQL backend operations.
SQL Queries tested on Microsoft SQL 2008 R2
SELECT Statement
-- W/o Parameter(s)
SELECT * FROM OPENQUERY (OracleSvr, 'SELECT name FROM JOBS');
-- W/ Parameter(s)
DECLARE @name nvarchar(max) = 'John';
SELECT * FROM OPENQUERY (OracleSvr, 'SELECT name FROM JOBS WHERE name = '' + @name + '' ');
INSERT Statement
INSERT OPENQUERY (OracleSvr, 'SELECT * FROM JOBS')
VALUES
(
'John' -- First Name
,'Doe' -- Last Name
,'Mortician' -- Title
,'INACTIVE' -- Status
);
UPDATE Statement
SELECT * FROM OPENQUERY (OracleSvr, 'SELECT * FROM JOBS WHERE Title = ''Mortician''')
SET Title = 'Grave Digger'
Delete Statement
DELETE OPENQUERY (OracleSvr, 'SELECT * FROM JOBS WHERE Id = 1');
Leave a Reply