' (inserting numeric value into sql query)

问题描述 投票:1回答:1

I am trying to insert a numeric variable 'Value ' into a decimal database column.

I used this query syntax :

SQL= 'INSERT INTO DB_Archive VALUES ( '''| dim1|''' , '''| dim2|''', '|Value|') ';

But it seems it's not correct way to declare a numeric column, which gave me this error :

Error : Incorrect syntax Near '|'

I tried then converting the numeric value to a string value like this :

zAmoun= NumberToString(Value);
SQL= 'INSERT INTO DB_Archive VALUES ( '''| dim1|''' , '''| dim2|''', '''|StringToNumber(zAmount)|''') ';

But it was a bad move to do , since it worked in the compilation and didnt return no error but in the execution it return this error here since the table column is a decimal :

Error : Error Converting data Type varchar to numeric

I would love if someone could help me know what is the correct syntax to declare a numeric column in sql query , since the first declaration is not working.

I would appreciate it very much.

ssas business-intelligence cognos cognos-10 cognos-tm1
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.