drop table bugs >create table bugs ( bugid int primary key) > >declare @Err int > >INSERT INTO bugs(BugId) values (123) >INSERT INTO bugs(BugId) values (123) >IF @@Error <> 0 > Print 'Failed' >ELSE > Print 'OK' >>
>>ALTER PROCEDURE [dbo].[Test1] >>AS >>SET NOCOUNT OFF >>INSERT INTO bugs(BugId) values ('sdf') >>IF @@error <> 0 >> Print 'Failed' >>ELSE >> Print 'OK' >>>>BugId is integer.
>>ALTER PROCEDURE [dbo].[Test1] >>AS >>SET NOCOUNT OFF >>INSERT INTO bugs(BugId) values (9999999999) >>IF @@error <> 0 >> Print 'Failed' >>ELSE >> Print 'OK' >>>>I got:
>>>DECLARE @ErrorInsert int, @ErrorUpdate int, >>> >>>INSERT INTO [111.11.1.11,1433].ipo.dbo.ui_userlookup >>> SELECT * FROM OPENQUERY(ADSI, 'SELECT ciscoEcsbuDtmfID, department, ciscoEcsbuDtmfID, mail, title, cn, SAMAccountName >>> FROM ''LDAP://DC=something,DC=something'' >>> WHERE objectCategory = ''Person'' >>> AND objectclass = ''user'' >>> AND title = ''Instrument Specialist*'' >>> AND numberrestrictiongroup <> ''*removed*'' >>> AND (accountexpires = 9223372036854775807 OR accountexpires = 0) >>> ORDER BY cn ') >>> >>>SELECT @ErrorInsert = @@Error >>> >>>UPDATE [111.11.1.11,1433].ipo.dbo.ui_userlookup >>> SET cusertype = 'IS' WHERE cusertype = cphoneext >>> >>>SELECT @ErrorUpdate = @@Error >>> >>> >>>IF @ErrorInsert <> 0 OR @ErrorUpdate <> 0 >>> BEGIN >>> >>> --send an email using exec master.dbo.xp_smtp_sendmail >>> END >>>>>>