The reports in our project use the procedure ChangeODBCDataSource to create a connection string in production. This works great. Currently I am working on an SQL function and it works if I use the Change DataSource Wizard to change the connection to my local database. When the original connection is used, the SQL function doesn't work.

Should this work? Do I have to use a connection string somehow?

dim sLocation

// Query only works when CAST function is used
let sLocation = CStr(SQL("select CAST([Loc_Len_QOH] as VarChar(250)) from dbo.[isIBTProductLocations](" + CInt({pordli.LENGTH}) + ") where [Product_Code] = '" + {PRODUCTS.PRODUCT_CODE} + "'"))

if (sLocation = "0") then 
   let sLocation = ""

return sLocation