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 2000 Forums
 Transact-SQL (2000)
 A little help on a stored procedure

Author  Topic 

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-29 : 05:17:22
Hi.
I have this procedure. So what i want to do is update ONLY the rows that has this specific number. Now when i run it, if it finds the number in the column, it updates ALL the rows to null and no the ones that only have the specific number.
thanks.

declare @mainid int
select @mainid = 6
Update tbltriggerfriend
set tbltriggerfriend.DNSid= NULL
where exists (SELECT tbltriggerfriend.DNSid
FROM dbo.tbltriggerfriend
where DNSid=@mainid )

kishore_pen
Starting Member

49 Posts

Posted - 2007-11-29 : 05:31:17
you can give another where clause in your update statement.
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-29 : 05:45:30
No it's ok.
It just needs
where DNSid=@mainid
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2007-11-29 : 05:48:38
No, all you need is:

declare @mainid int
select @mainid = 6
Update tbltriggerfriend
set tbltriggerfriend.DNSid= NULL
where DNSid=@mainid
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-29 : 08:41:23
Yes found it.
Thank RickD
Go to Top of Page
   

- Advertisement -