How can I insert a numeric variable in a statement from within a stored procedure (here is my attempt):
...
declare @SQL1 nvarchar(1500)
declare @calc numeric(18,2)
Set @calc = 18.00
SET @SQL1= 'insert into Table1(cv) values(' + @calc + ')'
The error I get on the last line is:
Error converting data type varchar to numeric.
If I insert a variable of type nvarchar like this:
SET @SQL1= 'insert into Table1(cn) values(''' + @column_name + ''')'
it works like a charm - but not when I try to insert a numeric field as above in the first example. Thank you!
PS: The table Table1 was correctly defined for its columns to match the variable types. Table1 has 2 columns: cn of type nvarchar(50) and cv of type numeric(18,2). @column_name is nvarchar(50) and @calc is numeric(18,2).
cnas a field, the othercv. Which is right, and what are their data types?