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
Robert Dannelly blog, Over the internet you can find me by "robert dannelly blog". The blog is an ongoing blog of my software engineering over technologies C#, VB.NET, Java, React, JavaScript, .NET Core Current, SQL Server 7 - Current Version, 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 links to help support this blog. Thank you. “As an Amazon Associate, I earn from qualifying purchases.”
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)