This is probably a bit of a strange question but how would I be able to determine inside a stored procedure if a linked server is Oracle or SQL server?
To give a bit of context, we have an application that in production queries a linked server (Oracle server, not ours) that contains PID (personally identifiable information) and thus we aren't allowed to use it in our dev and test environments. We unfortunately can't set up our own Oracle servers so in our environments for testing we have an SQL Server instance set up to act as the linked server with mocked up data in it.
For 99% of our queries this doesn't cause any issues except one with this line in it
WHERE LAST_MODIFIED > TO_DATE(''''' + CONVERT(nvarchar(24), @maxImageDate, 120) + ''''',''''YYYY-MM-DD HH24:MI:SS'''')
which we generally manually modify in dev and testing environments to be
WHERE LAST_MODIFIED > ''''' + CONVERT(nvarchar(24), @maxImageDate, 120) + '''''
My first idea was to attempt a query that would only work on oracle:
SELECT 1 FROM OPENQUERY(LinkedServerName, ''SELECT * FROM v$version'')
in a TRY/CATCH and run a different query if that fails but that causes the transaction to be uncommitable even after catching the error
We're starting to use octodeploy for automatic deployment and we could have the tentacle agent run an SQL script to modify the SP depending on the environment but would prefer to keep all the logic and code inside the SP and therefore in the repo but if we can't figure out another solution we'll probably go with that.
Any help would be greatly appreciated
SELECT * FROM sys.servers