Put all SQL Stored Procedures in BEGIN TRY > BEGIN TRANSACTION > IF ELSE blocks and use the following as a TEMPLATE
Create an output parameter so the source code can log the error and you can check the DB table for the error.
@ELog_ID int = 0 OUTPUT
SET XACT_ABORT, NOCOUNT ON;
BEGIN TRY
BEGIN TRANSACTION
IF
IF EXISTS (SELECT 'x' FROM People_tbl WHERE Email_Address = @Email_Address)
RAISERROR (N'Person is already in the database.',11,11, 'usr_Person_Add')
--PRINT 'Person is already in the database!'
ELSE
-- CRUD work
END TRY
BEGIN CATCH
--PRINT 'In the Catch Statement'
IF @@trancount > 0 ROLLBACK TRANSACTION
PRINT 'Process has reached the CATCH'
EXECUTE dbo.[usr_InsertErrorInfo];
SELECT @ELog_ID = max(ELog_ID)
FROM ErrorLog_tbl;
END CATCH
This blog shares my journey as a software engineer, along with personal reviews and life experiences I’ve gained along the way. “I have not failed. I've just found 10,000 ways that won't work.” — Thomas Edison. If you enjoy my content, please support it by clicking on ads (free for you, big help for me!) or by buying me a coffee on Ko-fi. Thank you!
Wednesday, February 27, 2019
Tuesday, February 26, 2019
PowerShell output to table and text file
Get-SPUser -Web "https://subdomain.domain.com" | format-table -autosize > e:\spusers.txt
https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-6
https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-6
Subscribe to:
Posts (Atom)