Question : SQL trigger is not allowing me to put an if statement in...

I am trying to create a sql trigger.  But when I run the create statement, i get the following error:
"Msg 4145, Level 15, State 1, Procedure tr_BatchProcessShipments_I, Line 9
An expression of non-boolean type specified in a context where a condition is expected, near 'return'."

What I am trying to do is check and see if the row that was inserted has the status column = shipped.  If it does not = shipped, then do not run the insert.

Any ideas?

Thanks.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
create trigger tr_BatchProcessShipments_I
on BatchProcessShipments
after INSERT
AS
begin

if(select * from inserted where "status" <>'Shipped')return;

insert into Xcarriershipping(shippingno, handlingunitid, Company, contact, phone, add1, add2, city, state, zipcode,
country, email, noofpacks, weight, unit, shipmethod, recpno, dim, payment, center, currency, customval, packdetails,
trackingno, prono, shipcost, discount, userid, pwd, date, delno, carrier, qty, senderid, ltlclass, status, canceldate, img, interface,
pono, invno, shiptofax, shiptohold)
select "sid", BatchNo, shiptocompany, shiptocontact, shiptophone, shiptoaddressline1, shiptoaddressline2, shiptocity, 
shiptostate, shiptopostalcode, shiptocountry, '', packagetotal, packageweight, 'LBS', "service", accountnumber, '', 
paymentterms, '', 'USD', '', '', trackingnumber, '', Freight, '0', 'Admin', '', shipdate, 'Delivery Doc Number', 
carrier, '', plantid, '0', "status", '', '0x', 'BATCH', '', '', '', ''
from inserted 
end
go

Answer : SQL trigger is not allowing me to put an if statement in...

Try this

create trigger tr_BatchProcessShipments_I
on BatchProcessShipments
after INSERT
AS
begin

if exists (select * from inserted where "status" <>'Shipped')return;

insert into Xcarriershipping(shippingno, handlingunitid, Company, contact, phone, add1, add2, city, state, zipcode,
country, email, noofpacks, weight, unit, shipmethod, recpno, dim, payment, center, currency, customval, packdetails,
trackingno, prono, shipcost, discount, userid, pwd, date, delno, carrier, qty, senderid, ltlclass, status, canceldate, img, interface,
pono, invno, shiptofax, shiptohold)
select "sid", BatchNo, shiptocompany, shiptocontact, shiptophone, shiptoaddressline1, shiptoaddressline2, shiptocity,
shiptostate, shiptopostalcode, shiptocountry, '', packagetotal, packageweight, 'LBS', "service", accountnumber, '',
paymentterms, '', 'USD', '', '', trackingnumber, '', Freight, '0', 'Admin', '', shipdate, 'Delivery Doc Number',
carrier, '', plantid, '0', "status", '', '0x', 'BATCH', '', '', '', ''
from inserted
end
go
Random Solutions  
 
programming4us programming4us