الصلاحيات الجديده فى محرك قواعد بيانات مايكروسوفت 2014


استمرارا لسلسلة المقالات الأخيرة التي تناولتها فى محرك قواعد بيانات مايكروسوفت فى المقال السابق تحدثنا عن الجداول المرنه والجداول الغير مرنه فى محرك قواعد بيانات مايكروسوفت 2014  هذا المقال الجديد ساقوم بشرح وتحليل الصلاحيات الجديده التى ظهرت مؤخرا مع محرك  قواعد بيانات مايكروسوفت 2014 والتى جاءت لكى تعالج بعض الثغرات الأمنية الخاصة بقواعد البيانات وابضا لتسهيل بعض الأعمال كما هو موضح ادناه :

لقد قامت مايكروسوفت بعمل مخطط جديد لصلاحيات محرك قواعد البيانات مايكروسوفت  2014 (SQL Server 2014) وجاءت فى هذا المخطط بثلاثه صلاحيات جديده التي قد حققـ خطوة متميزة في مجال امان قواعد البيانات لذا سوف اقوم بشرح هذه الصلاحيات الجديده وساقوم بعمل تطبيق على على كل واحده منهم لمعرفه متى يمكن استخدام هذا الصلاحيه وما هى وجه الأستفاده التى ستعود على أمن المعلومات من هذه الصلاحيات .

10

الصلاحيات الجديده فى محرك قواعد بيانات مايكروسوفت 2014 :

  1. CONNECT ANY DATABASE Permission.
  2. SELECT ALL USER Securables Permission.
  3. IMPERSONATE ANY login Permission.

 

يمكن الوصول الى هذه الصلاحيات عن طريق الخطوات الأتيه :

 

  1. Write click on SQL Server instance
  2. Select Properties
  3. From the write panel select Permission
  4. You will find now the 3 new Permission on the right

لأستكمال المقاله يرجى الذهاب الى هذا العنوان من هنا 

What is the meaning of SQL Command


Hello Followers today i will explain very small information but actually for me it is more good info because we should no the concept for our tools we are working on it so As we are DBA , DB Analyst or Developer we should know what is meaning of  SQL Command ? and what is SQL ?

What is SQL?

SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in relational database.

SQL is the standard language for Relational Database System. All relational database management systems like MySQL, MS Access, Oracle, Sybase, Informix, postgres and SQL Server use SQL as standard database language.

Also, they are using different dialects, such as:

  • MS SQL Server using T-SQL,
  • Oracle using PL/SQL,
  • MS Access version of SQL is called JET SQL (native format), etc

Meaning of  SQL Command :

SQL Commands are mainly classified into four types, which are DDL command, DML command, TCL command and DCL command.

SQL is mainly divided into four sub language

  • Data Definition Language(DDL)
  • Data Manipulation Language(DML)
  • Transaction Control Language(TCL)
  • Data Control Language(DCL)

command types in SQL DataBase

To check all my posts you can direct to my personal website or you can download this Excel sheet My Technical POSTS

View all my tips , LinkedIn Website Slideshare ,Youtube Channel. 1st QT Achievement in 2o15 

First quarter Achievements in 2015


Hello Guys

I am Mustafa El-Masry Principal Database Administrator & DB Analyst I am Production DBA and Development DBA also I am author and technical Writer to know more about me Visit my site from HERE
200 POST
Thank God by the end of year 2014 i completed one Hundred blog Post Published on the biggest SQL Server Community in the middle East SQL SERVER performance Tuning  you can check my posts on it from HERE  and in the first Quarter in 2015 i published 200 post in SQL Server technology in my Community {SQL DATABASE ADMINISTRATION}  you can check this list of my post from HERE you can check also the annual report from WordPress about my Community activity from HERE , and you can check my first arabic post in SQL Server 2014 from HERE  who love reading can check my technical document in SQL Server 2012 , 2014 Technology from HERE and at the end i am still new SQL Server Speaker i published four technical videos in SQL Server technology you can check it from HERE
Download all My Technical POSTS
DayMonth
Yesr2015
2014

SQL Server DMV Replication Monitoring Part 4


cloud-monitoring

Hello my followers  in the previous post i published part two in the series of (SQL Server DMV Replication Monitoring) and i explained very interested point for any DBA working on replication solutions by simple DMV depend on dynamic Query technique and on SQL Server cursor technology.

Summary of the previous posts

First Post :

  1. Publication Status
  2. Subscription Status
  3. Send Email by the Current status

Second Post :

  1. Replication information for the Complete setup.
  2. Find publication article.

Third Post :

How we can Check Distributor AGENT.

Replication in SQL Server Series  1 2 3 4 

DMV Replication Monitoring Series  1 2 3 4

Today i will Explain one new point it is very helpful and attractive , How we can Check LogReader AGENT Status

by the below Stored procedure we can Execute it from SQL Server AGENT to send to us notification mail if the LogReader JOB(s) FAILING OR STOPPED.

SOURCE POST : WWW.MostafaElmasry.WordPress.Com

[sql]

USE [MSDB]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create procedure [dbo].[replLogReaderStatusGet] 
@pRecipients varchar(255) = 'SQLGULF-dbconsultant@outlook.com' 
AS 

 
 SET NOCOUNT ON; 
 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; 
 
 DECLARE @is_sysadmin INT 
 DECLARE @job_owner sysname 
 DECLARE @job_id uniqueidentifier 
 DECLARE @job_name sysname 
 DECLARE @running int 
 DECLARE @cnt int 
 DECLARE @msg varchar(8000) 
 DECLARE @msg_header varchar(1000) 
 DECLARE @categoryid int 
 
 
select la.name,la.publisher_db, 
 case lh.runstatus 
 when 1 then 'Start' 
 when 2 then 'Succeed' 
 when 3 then 'In progress' 
 when 4 then 'Idle' 
 when 5 then 'Retry' 
 when 6 then 'Fail' 
 else 'Unknown' 
 end as runstatus 
 , lh.time, lh.comments 
from distribution..MSlogreader_history lh 
 inner join distribution..MSlogreader_agents la on lh.agent_id = la.id 
 inner join ( 
 select lh.agent_id, max(lh.time) as LastTime 
 from distribution..MSlogreader_history lh 
 inner join distribution..MSlogreader_agents la on lh.agent_id = la.id 
 group by lh.agent_id) r 
 on r.agent_id = lh.agent_id 
 and r.LastTime = lh.time 
where lh.runstatus not in (3,4) 
 
if @@rowcount > 0 
 
BEGIN 
 SELECT @job_owner = SUSER_SNAME() 
 ,@is_sysadmin = 1 
 ,@running = 0 
 ,@categoryid = 13 
 
 CREATE TABLE #job (job_id UNIQUEIDENTIFIER NOT NULL, 
 last_run_date INT , 
 last_run_time INT , 
 next_run_date INT , 
 next_run_time INT , 
 next_run_schedule_id INT , 
 requested_to_run INT , 
 request_source INT , 
 request_source_id sysname COLLATE database_default NULL, 
 running int , 
 current_step INT , 
 current_retry_attempt INT , 
 job_state INT) 
 
 INSERT INTO #job 
 EXECUTE master.dbo.xp_sqlagent_enum_jobs @is_sysadmin, @job_owner 
 
 SELECT @running = isnull(sum(j.running),-1),@cnt = count(*) 
 FROM #job j 
 join msdb..sysjobs s on j.job_id = s.job_id 
 where category_id = @categoryid 
 
 if @running <> @cnt 
 BEGIN 
 SELECT @msg_header = 'LogReader job(s) FAILING OR STOPPED. Please check replication job(s) ASAP.' 
 SELECT @msg_header = @msg_header + char(10) 
 SELECT @msg_header = @msg_header + '**************************************************************' 

 set @msg = '' 
 SELECT @msg = @msg + char(10)+'"' + s.[name] + '" - '+ convert(varchar, isnull(j.running,-1)) 
 FROM #job j 
 join msdb..sysjobs s on j.job_id = s.job_id 
 where category_id = @categoryid 
 and isnull(j.running,-1) <> 1 
 
 SELECT @msg = @msg_header + char(10) + nullif(@msg,'') 
 

 exec msdb.dbo.sp_send_dbmail 
 @recipients= @pRecipients , 
 @subject= 'Production Replication LogReader Alert', 
 @body = @msg 
END 
END 
GO
[/sql]

Now create new SQL Server agent job and execute this Stored procedure on it

sql]
USE [msdb]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[replLogReaderStatusGet]
@pRecipients = N'SQLGULF-dbconsultant@outlook.com'
SELECT 'Return Value' = @return_value
GO
[/sql]

Follow me to know more SQL Server DMV in Replication Monitoring

Follow  the Author :

View all my tips , LinkedIn Website Slideshare ,Youtube Channel.

SQL Server DMV Replication Monitoring Part 3


cloud-monitoring

Hello my followers  in the previous post i published part two in the series of (SQL Server DMV Replication Monitoring) and i explained very interested point for any DBA working on replication solutions by simple DMV depend on dynamic Query technique and on SQL Server cursor technology.

Summary of the previous posts

First Post :

  1. Publication Status
  2. Subscription Status
  3. Send Email by the Current status

Second Post :

  1. Replication information for the Complete setup.
  2. Find publication article.

Replication in SQL Server Series  

1     2      3       4 

DMV Replication Monitoring Series  1  2  3

Today i will Explain one new point it is very helpful and attractive , How we can Check Distributor AGENT Status

by the below Stored procedure we can Execute it from SQL Server agent to send to us notification mail if the Distributor JOB(s) FAILING OR STOPPED.

[sql]

USE [MSDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[replDistributorStatusGet]
@pRecipients varchar(255) = 'SQLGULF-DBConsultant@outlook.com'
AS
begin
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
DECLARE @is_sysadmin INT
DECLARE @JOB_owner sysname
DECLARE @JOB_id uniqueidentifier
DECLARE @job_name sysname
DECLARE @running int
DECLARE @cnt int
DECLARE @msg varchar(8000)
DECLARE @msg_header varchar(4000)
DECLARE @categoryid int

SELECT @job_owner = SUSER_SNAME()
 ,@is_sysadmin = 1
 ,@running = 0
 ,@categoryid = 10

CREATE TABLE #jobStatus (job_id UNIQUEIDENTIFIER NOT NULL,
 last_run_date INT ,
 last_run_time INT ,
 next_run_date INT ,
 next_run_time INT ,
 next_run_schedule_id INT ,
 requested_to_run INT ,
 request_source INT ,
 request_source_id sysname COLLATE database_default NULL,
 running int ,
 current_step INT ,
 current_retry_attempt INT ,
 job_state INT)

INSERT INTO #jobStatus
 EXECUTE master.dbo.xp_sqlagent_enum_jobs @is_sysadmin, @job_owner--, @job_id

--
select j.name, js.command, jss.running
from msdb.dbo.sysjobsteps js
 join msdb.dbo.sysjobs j on js.job_id = j.job_id
 join #jobStatus jss on js.job_id = jss.job_id
where step_id = 1 and subsystem = 'Distribution'
 and command like '%-Continuous'
 and jss.running <> 1
 if @@ROWCOUNT > 0
 BEGIN

 SELECT @msg_header = 'Distributor job(s) FAILING OR STOPPED. Please check replication job(s) ASAP.'
 SELECT @msg_header = @msg_header + char(10)
 SELECT @msg_header = @msg_header + 'Here is the list of Job(s) that are failing or stopped'
 SELECT @msg_header = @msg_header + char(10)
 SELECT @msg_header = @msg_header + '******************************************************************'

 set @msg = ''
 select @msg = @msg + CHAR(10) + j.name
 from msdb.dbo.sysjobsteps js
 join msdb.dbo.sysjobs j on js.job_id = j.job_id
 join #jobStatus jss on js.job_id = jss.job_id
 where step_id = 1 and subsystem = 'Distribution'
 and command like '%-Continuous'
 and jss.running <> 1

 SELECT @msg = @msg_header + char(10) + nullif(@msg,'')

 print @msg

 exec msdb.dbo.sp_send_dbmail
 @recipients= @pRecipients ,
 @subject= 'Production Replication Distributor Alert',
 @body = @msg
 END
drop table #jobStatus
end
GO

[/sql]

Now create new SQL Server agent job and execute this Stored procedure on it

[sql]

USE [msdb]
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[replDistributorStatusGet]
 @pRecipients = N'SQLGULF-DBConsultant@outlook.com'
SELECT 'Return Value' = @return_value

GO

[/sql]

Follow me to know more SQL Server DMV in Replication Monitoring

Follow  the Author :

View all my tips , LinkedIn Website Slideshare ,Youtube Channel.