Skip to content

Instantly share code, notes, and snippets.

@aevdokimenko
Last active May 16, 2018 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aevdokimenko/c758c1c3e47586eeaa30c5e9d3dee98a to your computer and use it in GitHub Desktop.
Save aevdokimenko/c758c1c3e47586eeaa30c5e9d3dee98a to your computer and use it in GitHub Desktop.
Example of using fn_GetSFDate
declare @soql nvarchar(1024), @sql nvarchar(1024)
-- This is s SOQL statement with SQL datetime, it will return all user
-- records created today.
-- We use it for illustration purposes only, also demonstrating a technique
-- for providing dynamic arguments for OPENQUERY() parameter.
select @soql = 'select * from user where createddate > '
+ dbo.fn_GetSFDate(GETDATE())
-- We need to wrap it into another string, as openquery cannot be called
-- with parameters
select @sql = 'select *
from openquery(SALESFORCE, ''' + @soql + ''')'
-- Let's see the final statement
print @sql
-- and execute it against our SFDC isntance
exec sp_sqlexec @sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment