Comments for Russ Thomas – SQL Judo https://sqljudo.wordpress.com The Art of SQL Server Database Administration, Development, and Career Skills for the Technically Minded Fri, 15 Feb 2019 04:15:54 +0000 hourly 1 http://wordpress.com/ Comment on A Group of Basic Availability Groups by Jay Joshi https://sqljudo.wordpress.com/2016/07/25/a-group-of-basic-availability-groups/comment-page-1/#comment-6223 Fri, 15 Feb 2019 04:15:54 +0000 http://sqljudo.wordpress.com/?p=2593#comment-6223 In reply to Russ Thomas ( @SQLJudo ).

Nope, that is not what we are looking for. But your article was very helpful. Thanks again.

]]>
Comment on A Group of Basic Availability Groups by Russ Thomas ( @SQLJudo ) https://sqljudo.wordpress.com/2016/07/25/a-group-of-basic-availability-groups/comment-page-1/#comment-6219 Fri, 15 Feb 2019 03:58:24 +0000 http://sqljudo.wordpress.com/?p=2593#comment-6219 In reply to Russ Thomas ( @SQLJudo ).

Never done it, but check this MSDN blog. He seems confident in its reliability for using it for multiple listener scenarios. https://blogs.msdn.microsoft.com/sqlalwayson/2012/02/03/how-to-create-multiple-listeners-for-same-availability-group-goden-yao/

]]>
Comment on A Group of Basic Availability Groups by Jay Joshi https://sqljudo.wordpress.com/2016/07/25/a-group-of-basic-availability-groups/comment-page-1/#comment-6215 Fri, 15 Feb 2019 03:28:33 +0000 http://sqljudo.wordpress.com/?p=2593#comment-6215 In reply to Russ Thomas ( @SQLJudo ).

Thanks for the answer mate!

But is it reliable to use the WSFC name and IP in place of SQL Server Listener?

]]>
Comment on A Group of Basic Availability Groups by Russ Thomas ( @SQLJudo ) https://sqljudo.wordpress.com/2016/07/25/a-group-of-basic-availability-groups/comment-page-1/#comment-6081 Thu, 14 Feb 2019 14:25:30 +0000 http://sqljudo.wordpress.com/?p=2593#comment-6081 In reply to Jay Joshi.

Yep, that’s essentially what a listener is. I prefer adding it on the SQL side.

]]>
Comment on A Group of Basic Availability Groups by Jay Joshi https://sqljudo.wordpress.com/2016/07/25/a-group-of-basic-availability-groups/comment-page-1/#comment-6012 Thu, 14 Feb 2019 07:14:19 +0000 http://sqljudo.wordpress.com/?p=2593#comment-6012 Can we use WSFC Virtual name and IP Address for the client to connect to all the BAGs?

When you create a new AG it will automatically create a role in WSFC. So by using the WSFC virtual name and IP address client will be redirected to the primary replica.

]]>
Comment on The Road to SQL Server 2014 MCSE by SQL New Blogger Digest - Week 3 » FLX SQL with Andy Levy https://sqljudo.wordpress.com/2015/04/21/the-road-to-sql-server-2014-mcse/comment-page-1/#comment-1746 Sat, 12 Jan 2019 14:09:04 +0000 http://sqljudo.wordpress.com/?p=2071#comment-1746 […] The Road to SQL Server 2014 MCSE | Russ Thomas – SQL Judo […]

]]>
Comment on A Group of Basic Availability Groups by Nicko https://sqljudo.wordpress.com/2016/07/25/a-group-of-basic-availability-groups/comment-page-1/#comment-996 Fri, 16 Mar 2018 18:04:35 +0000 http://sqljudo.wordpress.com/?p=2593#comment-996 I created a stored procedure based on Russ’ script within the Master database that is executed every 10 seconds via an Agent job (perhaps there is a better way to do this?). Anyways, here is the stored procedure in case anyone might find it useful:

CREATE PROCEDURE [dbo].[LoyalAGFailover]
— Add the parameters for the stored procedure here
@DBMailProfile VARCHAR(MAX),
@AvailabilityGroupKingName VARCHAR(MAX)
AS
BEGIN
— SET NOCOUNT ON added to prevent extra result sets from
— interfering with SELECT statements.
SET NOCOUNT ON;

— Insert statements for procedure here
— Set the Database Mail Profile to use on this server
DECLARE @profile VARCHAR(MAX) = @DBMailProfile;

— Set the King Availability Group
DECLARE @ag_king_name VARCHAR(MAX) = @AvailabilityGroupKingName;
DECLARE @ag_king UNIQUEIDENTIFIER;

SELECT
@ag_king = ag_id
FROM sys.dm_hadr_name_id_map
WHERE ag_name = @ag_king_name;

— Create information table of all Loyal Availability Groups that are Secondary
PRINT ‘Filling information table with all Loyal Availability Groups that are Secondary on this server’
DECLARE @AGs as table
(
RowNum INT,
AG_Name VARCHAR(MAX),
AG_ID UNIQUEIDENTIFIER,
AG_Role VARCHAR(MAX)
);
INSERT INTO @AGs
SELECT
Row = ROW_NUMBER() OVER(ORDER BY ag_name ASC),
AG_Name = m.ag_name,
AG_ID = m.ag_id,
AG_Role = s.role_desc
FROM sys.dm_hadr_availability_replica_states s
JOIN sys.dm_hadr_name_id_map m
on m.ag_id = s.group_id
WHERE
m.ag_id != @ag_king
and is_local = 1
and s.role_desc = ‘Secondary’
— Specify specific availability groups to fail over automatically with the King availability group
and ag_name in (‘AG1′,’AG2′,’AG3’); — ********** THIS NEEDS TO BE SET MANUALLY FOR EACH SERVER IF USED **********
PRINT ‘Informational table has been filled’

DECLARE @ag_loyal_id UNIQUEIDENTIFIER;
DECLARE @ag_loyal_name VARCHAR(MAX) = ”;
DECLARE @count INT;

SELECT @count = COUNT(1) FROM @Ags; — Count of Loyal Availability groups that need to failover
PRINT ‘There are ‘ + cast(@count as nvarchar(10)) + ‘ Loyal Availability groups that need to failover’
PRINT ‘Checking if ‘ + cast(@ag_king_name as nvarchar(max)) + ‘ Availability Group is the Primary on this server’
IF — Check if King Availability Group is Primary on this server
(
SELECT role_desc
FROM sys.dm_hadr_availability_replica_states
WHERE
group_id = @ag_king
and is_local = 1
) = ‘PRIMARY’ and @count > 0
BEGIN — King Availability Group is Primary, Failover any Loyal Availability Groups that are currently Secondary
PRINT cast(@ag_king_name as nvarchar(max)) + ‘ Availability Group is the Primary on this server, failing over any Loyal Availability Groups that are currently Secondary’
WHILE @count > 0
BEGIN
SELECT
@ag_loyal_id = ag_id,
@ag_loyal_name = ag_name
FROM @AGs
WHERE
@count = RowNum;
SELECT @count = @count – 1;
DECLARE @message VARCHAR(MAX);
DECLARE @recipients VARCHAR(MAX) = ‘[email protected]’;
DECLARE @subject VARCHAR(MAX);

BEGIN TRY
DECLARE @sqlcmd VARCHAR(max);
SET @sqlcmd = ‘ALTER AVAILABILITY GROUP [‘ + @ag_loyal_name + ‘] FAILOVER;’;
EXEC (@sqlcmd);
PRINT ‘Failover of ‘ + cast(@ag_loyal_name as nvarchar(max)) + ‘ SUCCEEDED, sending email’
SET @subject = ‘Availability Group Failover to ‘ + @@SERVERNAME + ‘ SUCCEEDED for [‘ + @ag_loyal_name + ‘]’;
SET @Message = ‘Availability Group Failover to ‘ + @@SERVERNAME + ‘ SUCCEEDED for [‘ + @ag_loyal_name + ‘]’;
EXEC msdb.dbo.sp_send_dbmail
@profile_name = @profile,
@recipients = @recipients,
@subject = @subject,
@body = @Message;
END TRY

BEGIN CATCH
PRINT ‘Failover of ‘ + cast(@ag_loyal_name as nvarchar(max)) + ‘ FAILED, sending email’ + ERROR_MESSAGE()
SET @subject = ‘Availability Group Failover to ‘ + @@SERVERNAME + ‘ Failed for [‘ + @ag_loyal_name + ‘]’;
SET @Message = ‘Availability Group Failover to ‘ + @@SERVERNAME + ‘ Failed for [‘ + @ag_loyal_name + ‘]’+’
‘+ERROR_MESSAGE();

EXEC msdb.dbo.sp_send_dbmail
@profile_name = ‘alasql0002’,
@recipients = @recipients,
@subject = @subject,
@body = @Message;
END CATCH;
END;
END;
ELSE
PRINT ‘Either ‘ + cast(@ag_king_name as nvarchar(max)) + ‘ Availability Group is not the Primary on this server, or there are no Loyal Availability Groups that need to fail over – FINISHED’
END

]]>
Comment on Monthly DBA Challenge by T-SQL FizzBuzz | SQL Studies https://sqljudo.wordpress.com/monthly-dba-challenge/comment-page-1/#comment-786 Wed, 17 May 2017 13:00:53 +0000 http://sqljudo.wordpress.com/?page_id=922#comment-786 […] for something to write about this evening and came across one of Russ Thomas’ (b/t) old monthly challenges (Feb […]

]]>
Comment on A Group of Basic Availability Groups by Shane O'Neill https://sqljudo.wordpress.com/2016/07/25/a-group-of-basic-availability-groups/comment-page-1/#comment-758 Thu, 23 Mar 2017 10:48:25 +0000 http://sqljudo.wordpress.com/?p=2593#comment-758 Thanks Russ, this is actually the only resource I’ve found that actually states plainly and clearly “Yes, you can have multiple BAGs on the same instance”.

]]>
Comment on What Every DBA and SWE Should Know About EF by Otto https://sqljudo.wordpress.com/2014/12/29/what-every-dba-and-swe-should-know-about-ef/comment-page-1/#comment-754 Wed, 15 Mar 2017 16:58:40 +0000 http://sqljudo.wordpress.com/?p=1914#comment-754 Hello Russ,

I’ve watched your courses about database security and about using Entity Framework. If I’m allowed to, please let me ask some questions about ORMs and security to you as somebody who is familiar with both topics*.
At my company, we are currently discussing about using ORM (EF6) and Stored Procedures (sprocs) with reference to security:
• use sprocs only, all free** CRUD operations are forbidden on the database to gain security, using an ORM does not provide significant advantages anymore
• use it in a mixed fashion, get the best of both worlds but having trade offs in security
o forbidding free CUD-Operations and perform them via sproc, free Selects are allowed, using the ORMs ability to easily make DB queries
o allow free CRUDs and using the ORMs ability to easily make DB queries and to save modified object graphs
o forbidding all Delete operations …??
Is it a good a way to gain security by forbidding free CRUD? Or is it better to focus on other security mechanisms as you described them in your course with resources saved by using an ORM?

Thanks in advance
Otto

*There are a lot of discussion you can find in the web, but it seems to me, people who are familiar with ORMs are debating with people who are familiar with sprocs with people who are familiar with security – not knowing if anybody is getting the whole picture (https://kevinlawry.wordpress.com/2012/08/07/why-i-avoid-stored-procedures-and-you-should-too/)
** free in the sense of CRUD operations that are not encapsulated in a sproc

]]>