Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
@@Error
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01113074
Message ID:
01113110
Views:
19
Here is my stored procedure
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
When there is a problem with the insert statment the @@error is not being assigned and program never gets to the if statement.

Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform