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 is about my history as a software engineer utilizing technologies C#, Java, React, JavaScript, .NET Core, SQL Server , Oracle, GIT, GitHub, Jira, Azure, AWS and HTML5. “I have not failed. I've just found 10,000 ways that won't work.” Thomas A. Edison. Please click on all my ADVERTISING links to help support this blog. 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)