Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 insert based on multiple like conditions

Author  Topic 

quarinteen
Starting Member

40 Posts

Posted - 2008-09-26 : 16:14:41
I need to do an insert based on multiple like statements how can i do that? the following is what i tried and it didnt work

insert into pcinfo (isvalidNode) values('1') where machineName like '%comp1%' or '%comp2%' or '%comp3%'

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-09-26 : 16:27:04
insert into pcinfo (isvalidNode) values('1') where machineName like '%comp1%' or machineName like '%comp2%' or machineName like '%comp3%'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-27 : 02:06:18
quote:
Originally posted by quarinteen

I need to do an insert based on multiple like statements how can i do that? the following is what i tried and it didnt work

insert into pcinfo (isvalidNode) values('1') where machineName like '%comp1%' or '%comp2%' or '%comp3%'


update pcinfo
set p.isvalidNode=1
where machineName like '%comp1%' or
machineName like '%comp2%' or
machineName like '%comp3%'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-27 : 02:07:36
and why you didnt learn it from solution provided earlier

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111304
Go to Top of Page
   

- Advertisement -