The INSERT syntax I used is
INSERT INTO TableName VALUES (...)
The UPDATE syntax that I used is
UPDATE TableName SET ColumnName=Value WHERE ...
So, in all my code I need to generate 2 lines, which will lead to something like this
insertStr = "(27, 'John Brown', 102)";
updateStr = "ID=27, Name='John Brown', ItemID=102";
and then use them separately
"UPDATE TableName SET " + updateStr + " WHERE ID=27 " +
"IF @@ROWCOUNT=0 "+
"INSERT INTO TableName VALUES (" + insertStr + ")"
This starts to bother me when I work with tables with 30 columns.
Can't create only one row for use in both INSERT and UPDATE?
eg. using insertStr above in an UPDATE statement or updateStr in an INSERT statement or a completely new way?
source
share