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
 General SQL Server Forums
 New to SQL Server Programming
 comparing two fields inside the storedprocedure

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2008-04-09 : 16:53:58
My situation is this: I have a requirement table,in the requirement table i have a field which is allow_multiple,if it allows multiple the value is 1 and 0 if it will not allow and also I have an insert storedprocedure for inserting licenses which will be added in the Staffl table.When i insert a new license for the staff,it should check in the requirement table if the new inserted lincense does have 0 or 1 value in the allow multiple field.If it has a value of 0 the new license should not be inserted.What would be the good way to compare the existing licenses of the staff and the newluy added?

Funnyfrog

TallOne
Starting Member

49 Posts

Posted - 2008-04-09 : 17:22:54
Maybe try something like this

DECLARE @Allow AS TINYINT
SET @Allow = (SELECT allow_multiple From requirements) -- <-- might need a where clause
If @Allow = 1
BEGIN
--YOUR INSERT
END

Go to Top of Page
   

- Advertisement -