@ ITEM - as the input parameter
Want to use the following statement cycle
DECLARE @ n int, @ SQLS NVARCHAR (4000)
The set @ n=1
While @ n
=15The BEGIN
The set @ SQLS="INSERT INTO Table1 (item, unitprice, usage, finalprice) '
The set @ SQLS=@ SQLS + 'select' + @ ITEM,,,,,,,,,,,,,,,,,,
The exec (@ SQLS)
Select @ n=@ the n + 1
END
How to write the SQL splicing statements. Another @ n is int, can't seem to and field splices,
Thank you very much,
CodePudding user response:
'item' + cast (@ n as varchar (5)) can be appliedCodePudding user response:
Set@ SQLS="INSERT INTO Table1 (item + cast (@ n as varchar (5)) +
'and unitprice' + cast (@ n as varchar (5)) +
'and the usage of' + cast (@ n as varchar (5)) +
', finalprice '+ cast (@ n as varchar (5)) +') '
Words what this circular insert is to be inserted, @ what ITEM