Sergey,
Like always - right on the money! Thanks for your assistance yet again.
Al
>Hi Allan,
>
>When you concatenate string (char, nchar) with other data types, SQL Server may perform implicit conversion of those types to the char/nchar. In BOL
CAST and CONVERT there's a chart that shows all explicit and implicit data type conversions allowed for SQL Server system-supplied data types. According to it, money data type can be converted to nchar only explicitly (CAST or CONVERT).
(TransactionDetails.AmountMN Between '+
> CAST(@LowAmountMN AS nvarchar(32) + ' AND '+
> CAST(@HighAmountMN AS nvarchar(32)) + ')' +
I prefer always use explicit conversion so I can control result of it.
>>
>>I have the following query dynamically contstructed in a stored procedure:
>>
>>
>...
>>'WHERE (ReportControl.ReportControlID = ' + @ReportControlID + ') and ' +
>>' (TransactionDetails.CUSubBranchID = ' + @CUBranchID + ') and ' +
>>' (Reports.ReportIdentifierVC = '+ @SwitchReportVC + ') and '+
>>' (TransactionDetails.AmountMN Between '+ @LowAmountMN +
>' AND '+ @HighAmountMN + ')' +
>>'ORDER BY ' + @SortOrder)
>>
>>return
>>
>>The query runs fine without the last where clause:
>>
>>
>' (TransactionDetails.AmountMN Between '+ @LowAmountMN + '
>AND '+ @HighAmountMN + ')' +
>>
>>However when running this query - where @LowAmountMN and @HighAmount are indeed the Money Datatype - as is field AmountMN - I get the following error:
>>
>>
>>Server: Msg 257, Level 16, State 3, Procedure up_CustomReport1, Line 121
>>[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type money to nvarchar is not allowed. Use the CONVERT function to run this query.
>>
>>
>>I can't figure out the problem - any ideas???
Al Williams
Anola MB, CANADA