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 and like

Author  Topic 

quarinteen
Starting Member

40 Posts

Posted - 2008-09-24 : 12:11:59
can anyone help me out the following statement bombs..

insert into Pcinfo (isvalidnode) values('1') where machineName like '%ws%'

bjoerns
Posting Yak Master

154 Posts

Posted - 2008-09-24 : 12:13:56
Does it nothing? Gives an error message? Deletes Pcinfo table? Blasts the server?
Go to Top of Page

nduggan23
Starting Member

42 Posts

Posted - 2008-09-24 : 12:15:07
You need to provide a table definition to be sure but if isvalidnode is a bit column then remove the '' around 1. otherwise i cant see anything wrong with the statement.
Go to Top of Page

quarinteen
Starting Member

40 Posts

Posted - 2008-09-24 : 12:20:59
no isvalidnode is a varchar max. I get the error

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'where'.
Go to Top of Page

bjoerns
Posting Yak Master

154 Posts

Posted - 2008-09-24 : 12:25:13
update Pcinfo set isvalidnode = '1' where machineName like '%ws%'
insert inserts a whole row.


Go to Top of Page

quarinteen
Starting Member

40 Posts

Posted - 2008-09-24 : 15:05:56
update Pcinfo set isvalidnode = '1' where machineName like '%ws%' that worked so now how do I select the following

select * from routerinfo where isvalidnode = null

this returns nothing although there is several in that column that are null
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-24 : 15:09:16
quote:
Originally posted by quarinteen

update Pcinfo set isvalidnode = '1' where machineName like '%ws%' that worked so now how do I select the following

select * from routerinfo where isvalidnode = is null

this returns nothing although there is several in that column that are null


null is not stored as a value so it wont work with comparison operators like =. so use is null for comparison unless you have set ansi nulls settings off.
Go to Top of Page

quarinteen
Starting Member

40 Posts

Posted - 2008-09-24 : 15:16:23
thanks that did it
Go to Top of Page
   

- Advertisement -