{"id":53,"date":"2011-07-08T13:38:55","date_gmt":"2011-07-08T13:38:55","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2011\/07\/08\/create-proxy-step-by-step-in-detail\/"},"modified":"2011-07-08T13:38:55","modified_gmt":"2011-07-08T13:38:55","slug":"create-proxy-step-by-step-in-detail","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2011\/07\/08\/create-proxy-step-by-step-in-detail\/","title":{"rendered":"CREATE PROXY – STEP BY STEP – IN DETAIL"},"content":{"rendered":"
How to create proxy in SQL Server?<\/strong><\/p>\n Berore reading this post if you want to understand what a proxy is then you can go through the following post here<\/a><\/p>\n So now coming to creation of proxy there are basically two ways:<\/p>\n First method would be using the SSMS(SQL SERVER MANAGEMENT STUDIO) – Object Explorer First I would explain how to create proxy using Create proxy query and later in the post I would show how to create proxy using SSMS Object Explorer.<\/p>\n Create Proxy using SQL QUERY:<\/strong><\/p>\n Syntax for Creating proxy: So in the steps to create proxy here first we need to create a credential. First let us create a credential, Query to create credential: Now that credential is created we can create an agent proxy now.<\/p>\n Query to create proxy:<\/p>\n [sql] SELECT @proxy_id procedure sp_add_proxy has to be run on msdb database. The above query creates a proxy using credential cred_jhon. To map this proxy to a subsystem the procedure sp_grant_proxy_to_subsystem has to be used.<\/p>\n [sql]<\/p>\n EXEC msdb.dbo.sp_grant_proxy_to_subsystem @proxy_name=N’proxy1′, @subsystem_id=11 [\/sql]<\/p>\n The above command maps this proxy to SSIS Subsystem.<\/p>\n Following are the subsystemid’s:<\/p>\n Creating Proxy Using Object Explorer – SSMS:<\/strong><\/p>\n Following are the steps to create proxy using SSMS: Connect to SQL server in object explorer<\/p>\n
\nSecond method would be using CREATE PROXY Query.<\/p>\n
\n[sql]
\nsp_add_proxy @proxy_name = <<name_of_the_proxy>> ,
\n@description = <<description_of_proxy>> ,
\n@credential_name = <<name_of_the_credential>> ,
\n@credential_id = <<credential_id>> ,
\n@enabled = <<1 or 0>> ,
\n@proxy_id = <<proxy_id >> OUTPUT
\n[\/sql]<\/p>\n
\nFurther information about creating credentials can be found here<\/a><\/p>\n
\nlets call it cred_jhon,
\nSo let us suppose the username and passowrd be jhon and pass000<\/p>\n
\n[sql]
\nUSE
\n[master]
\nGO
\nCREATE CREDENTIAL [cred_jhon] WITH IDENTITY = N’jhon’, SECRET = N’pass000′
\nGO
\n[\/sql]<\/p>\n
\ndeclare @proxy_id int
\nexec sp_add_proxy @proxy_name = ‘proxy1’,
\n@description = ‘simple proxy’,
\n@credential_name = ‘cred_jhon’, –The credential that we created above.
\n@enabled = 1, –its enabled
\n@proxy_id = @proxy_id OUTPUT<\/p>\n
\n[\/sql]<\/p>\n
\nexecute permissions on sp_add_proxy are given to the members of sysadmin role.<\/p>\n
\nNow that the proxy is created but this will be un assigned as we did not map it to any subsystem.
\nMore info about subsystems can be found here<\/a><\/p>\n
\nGO<\/p>\n\n\n
\n subsystem_id<\/th>\n Sub System<\/th>\n<\/tr>\n \n 2<\/td>\n Microsoft ActiveX Script<\/td>\n<\/tr>\n \n 3<\/td>\n Operating System<\/td>\n<\/tr>\n \n 4<\/td>\n Replication Snapshot Agent<\/td>\n<\/tr>\n \n 5<\/td>\n Replication Log Reader Agent<\/td>\n<\/tr>\n \n 6<\/td>\n Replication Distribution Agent<\/td>\n<\/tr>\n \n 7<\/td>\n Replication Merge Agent<\/td>\n<\/tr>\n \n 8<\/td>\n Replication Queue Reader Agent<\/td>\n<\/tr>\n \n 9<\/td>\n Analysis Services Command<\/td>\n<\/tr>\n \n 10<\/td>\n Analysis Services Query<\/td>\n<\/tr>\n \n 11<\/td>\n SSIS package execution<\/td>\n<\/tr>\n \n 12<\/td>\n PowerShell Script<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\nOpen SQL SERVER MANAGEMENT STUDIO<\/p>\n