Friday, February 8, 2019

Grant Access SQL Server Agent using tSQL/SSMS, SQL Server

When you need to grant the user to access (read/manage) "SQL Server Agent", you can do it using either using SSMS or tSQL.

There are three (3) fixed database roles available under "msdb" database to access SQLServerAgent. Roles are as below...
  • SQLAgentOperatorRole: This is the most privileged of the SQL Server Agent fixed database roles. Members can create/delete/modify any job & schedules (own by any user). Also, Members of this role can view properties for operators and proxies, and enumerate available proxies and alerts on the server.
  • SQLAgentReaderRole: Members have permission to view the properties of any job & schedules (own by any user). Members cannot change job ownership which is own by others to gain access.
  • SQLAgentUserRole: Members have permissions on only local jobs and schedules that they own. They can also view the operators. No permission to view the Proxy node BUT in Job  Step they can see to use only.
For more details about the Roles, please visit below link ...
https://docs.microsoft.com/en-us/sql/ssms/agent/sql-server-agent-fixed-database-roles

Now, let's grant the appropriate role to a user. There are two ways you can do it.
  1. Using SSMS: Please follow below steps to grant a user to an SQLAgentRole
  2. SSMS - Grant SQL Server Agent Role
    1. Expand the Database Server Node.
    2. Expand Security Node.
    3. Select the User where you want to grant access. Right click on it and go to Properties
    4. In Properties window, navigate "User Mapping" from the left pane.
    5. From the right pane, select/tick on "msdb" database.
    6. In the bottom pane of the same window, select appropriate fixed database role [discussed above].
    7. All set, now click OK and check :)
  3. Using tSQL: Using the below script you can grant any role to a user...
    1. Change the user name and role name accordingly
    2. USE [msdb]
      GO
      CREATE USER [MEDAVANTE\testUser]
      FOR LOGIN [MEDAVANTE\testUser]
      GO
      USE [msdb]
      GO
      ALTER ROLE [SQLAgentReaderRole]
      ADD MEMBER [MEDAVANTE\testUser]
      GO

Hope this post will help you to grant SQLServerAgent fixed role access to any user.

Wednesday, February 6, 2019

How to find the SQL Server Instance name

First, check that the SQL Server service is installed in the machine/server bu using "services.msc".

For that, press WindowsKey+R to get the Run dialog. Then type "Services.msc". Then find the service "SQL Server ...".

If you get the SQL Server service in the service list, that means SQL Server is installed in this server/PC/Machine.

Now let's find the instance name...

First Option [will work for all - Recomendade]
go to start menu and find "SQL Server Configuration Manager". open it.
point to the "SQL Server Services".
from the right pane find the service "SQL Server (instance name)" [as you get in the service.msc list]
now Right click on it and go to "Properties".
now click on "Server" Tab.
you will get all the information here .. look at the below image.

Configuration Manager

Second Option [sqlcmd]
Open "Command Prompt" [ press "WindowsKey+R", then type "cmd" on run dialog]
in the command prompt console -> type "sqlcmd -L"
you will get the server name and the instance name most luckily
check below image ...

sqlcmd -L

Friday, February 1, 2019

SSIS Connection Problem, "The specified service does not exist as an installed service."

If you get the error "The specified service does not exist as an installed service.", please dont be panic!

This is a very common issue. Follow below steps to ride on it.

1. First, check the SSIS is installed in the server. for that go to services.msc and try to find the service "SQL Server Integration Services xx" [xx can be 12/13/14 ..]. If there is no service like this, means no SSIS has been installed in this server. OR if you find the service, please follow below steps.

2. This is must, use the same version of SSMS to access the SSIS. If you have the DB permission, then check the DB version. most luckily SSIS and DB version is same. To be sure the version number, I always pick the service number [for my case it was "SQL Server Integration Services 13"]. 13 means SQL Server 16!

3. Once you get the version number of SSIS/DB. Download the SSMS for the same version from here. after install, try to connect to SSIS, I hope you will win!


Also, you can download the Free Developer Edition of SQL Server (SSIS Included) from here .. https://www.microsoft.com/en-us/sql-server/sql-server-downloads