Monday, August 3, 2015

Quick reference - SQL_FormatStrings()

 "SQL_FormatStrings() function which will double up single quote characters and also surround the string with starting and ending single quotes. This will avoid the issues caused by a single quote in the data terminating a string early". says Developing for GP

Use this when doing passthrough SQL when you need to specify string values.

Example:
local text sql;
sql = "SELECT * FROM myTable WHERE Field = " + SQL_FormatStrings("Hello");

That will turn into SELECT * FROM myTable WHERE Field = 'Hello'

Ref: http://blogs.msdn.com/b/developingfordynamicsgp/archive/2013/11/04/quick-tip-unusual-behaviour-when-working-with-sql-server-from-dexterity.aspx 

No comments:

Post a Comment

There was an error in this gadget