Last active
May 16, 2018 06:05
-
-
Save aevdokimenko/c758c1c3e47586eeaa30c5e9d3dee98a to your computer and use it in GitHub Desktop.
Example of using fn_GetSFDate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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