Somehow it doesn't work the way I would like to....
Couple of things in reply:
* This msg. should be in a TD section somewhere, depending on your version of TD. This is not a 'general discussion' issue -- it is an issue about TD and a SQL query using SqlPrepareAndExecute().
* "doesn't work" -- how doesn't it work? Do you get a SQL error? If so, what is the error information?
If the Sql function returns FALSE there is -- or should be -- a SQL error somewhere, though this might be a TD error that is caught in the router before the statement is transmitted to the DB because the router, during its parsing of the string, does not understand the syntax.
* You have 3 SQL statements there:
1 - "if ..." -- almost certainly this will fail. That's a conditional and TD/router won't understand the token 'If'
2 - "output " -- ditto, likely the router (or the DB?) don't understand this token
3 - "sTemp = 'C:\\TestFile.TXT'
Set sCmd="insert into #output EXEC master.dbo.xp_cmdshell 'dir \"" || sTemp || "\"'"
That looks like you are trying to send a SQL command for a file on the server-side and again "insert... EXEC..." is likely a syntax that the router won't understand.
I will retrieve the file size & datetime of an file which is located on MSSqlServer (2008)
You might have to do that using a stored procedure and call the SP from within TD.
FYI, for an issue like -- or a problem if you try a SP -- you will need to provide us a complete test case that we can here to test and/or debug.
I am moving this msg. topic to the TD v5.2 section, Fap.