hai,
how to insert a value in a table with where condition in sql server 200.
insert into replies values title='network' where user1="bala"
i use this condition but the error occurs how to solve this
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted Dec 29, 2010, 7:58 PM EST
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 29, 2010, 7:56 PM EST
You can use INSERT with WHERE clause like
insert into replies(col1,col2) values('network','VALUE')
SELECT col1,col2 From UserTable
where user1="bala"
krithika muthukrishnanRank #8,369 · 223 reputationPosted Dec 29, 2010, 9:53 PM EST
Sorry i forget that for using update condition thanks,
uday kanna3 reputationPosted Dec 29, 2010, 10:21 PM EST
Vijay YadavRank #1,637 · 943 reputationPosted Jan 20, 2011, 7:54 PM EST
You cannot insert new row with where conditions
Thanks,
Vijay
Subhendu DeRank #1,108 · 1.7K reputationPosted Jan 21, 2011, 4:41 PM EST
I am sure you can use where clause with insert statement... Run the following example in SQL Server 2008 R2
create table maintable(col1 integer,col2 varchar(20))
insert into maintable(col1,col2) values(1,'AAA')
insert into maintable(col1,col2) values(2,'BBB')
insert into maintable(col1,col2) values(3,'CCC')
insert into maintable(col1,col2) values(4,'DDD')
insert into maintable(col1,col2) values(5,'EEE')
insert into maintable(col1,col2) values(6,'FFF')
insert into maintable(col1,col2) values(7,'GGG')
insert into maintable(col1,col2) values(8,'HHH')
create table copytable(col1 integer,col2 varchar(20))
select * from maintable
select * from copytable
insert into copytable
select * from maintable
where col1 between 1 and 5
select * from copytable