sql server - SQL Insert Query With Condition -
i trying insert values 1 column of table when condition satisfied.
note: table contains data columns 1 empty. insert value 1 column depending on clause.
i have query:
insert <table_name> (column_name) (value) <condition>
i getting exception:
incorrect syntax near keyword
i able using update:
update <table_name> set <col_name> <condition>
but wondering why insert query failing. advise appreciated.
as understand problem, have data in 1 row, , 1 column in row not have value, want add value in column.
this scenario update existing row, not insert new row. have use update clause when data present , want modify record(s). choose insert when want insert new row in table.
so in current scenario, update clause friend clause want modify subset of records not all.
update <table_name> set <col_name> <condition>
insert clause not have clause per rdbms syntax(i think). insert condition less sql query, while select, update, delete conditional commands, can add clause in later ones.
Comments
Post a Comment