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)
 Sql Query Help

Author  Topic 

saidev
Posting Yak Master

101 Posts

Posted - 2006-07-11 : 15:51:14
I have a table called EMP, Here is the Fields


ID TempID

1 0
2 0
3 0
4 0
5 0
6 1
7 2
8 3
9 4
10 5

If ID = TempID i,e 1 = 1 then i should not allow the user to update this table. how can we check this condition in Sql Query. can you guys help me with the query.

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-07-11 : 17:05:56
I assume you'll already know what user you are after, so:

IF EXISTS (SELECT * FROM EMP WHERE ID = @YourIDvariable AND TempID = @YourIDvariable)
-- allow update

Tara Kizer
aka tduggan
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-07-12 : 00:01:25
or

update tablename
set ....
where id<>tempID and id=@id



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -