| Author |
Topic |
|
Valentin-
Starting Member
7 Posts |
Posted - 2003-05-10 : 12:40:18
|
| CREATE PROCEDURE adm_showcontact( @DomainID INT)AS DECLARE @Registrant INT DECLARE @Admin INT DECLARE @Tech INT IF EXISTS(SELECT @Registrant = registrant, @Admin = admin, @Tech = tech, domain_id, domain_name, domain_type, product_type,billing FROM domains WHERE domain_id = @DomainID AND state = 0)THEN BEGINSELECT reg_name, org, adress1, adress2, adress3, city, province, postalcode, telephone, fax, emailFROM contacts WHERE contact_id = @Registrant OR contact_id = @Admin OR contact_id = @TechENDErrorCode:Server: Msg 170, Level 15, State 1, Procedure adm_showcontact, Line 12Line 12: Incorrect syntax near '='.Could anyone help me?Thanks a lot.Bye |
|
|
hemchand
Starting Member
2 Posts |
Posted - 2003-05-10 : 14:19:38
|
| An assignment to a variable is not possible in an expression which can return only true or false. Try the assignent within the 'IF' block. Also the 'Then' you have used is not required.ByeTry this:CREATE PROCEDURE adm_showcontact ( @DomainID INT ) ASIF EXISTS (SELECT * FROM domains WHERE domain_id = @DomainID AND state = 0) BEGIN SELECT reg_name, org, adress1, adress2, adress3, city, province, postalcode, telephone, fax, email FROM contacts AS a INNER JOIN domains AS b ON b.domain_id = @DomainID AND b.state = 0 AND (a.contact_id = registrant OR a.contact_id = admin OR a.contact_id = tech)END |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-05-10 : 16:12:38
|
| There may be a very good reason, but why bother with the test at all? If it doesn't exist, an empty recordset is the worst possible problem.Try this: CREATE PROCEDURE adm_showcontact ( @DomainID INT ) AS SELECT reg_name, org, adress1, adress2, adress3, city, province, postalcode, telephone, fax, email FROM contacts AS a INNER JOIN domains AS b ON b.domain_id = @DomainID AND b.state = 0 AND (a.contact_id = registrant OR a.contact_id = admin OR a.contact_id = tech) GO |
 |
|
|
|
|
|