Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a variable that contains a stored procedure name:

DECLARE @stored_procedure_name varchar(512);
SET @stored_procedure_name = 'some_stored_procedure_name';

How can I execute the stored procedure (without passing in any arguments)?

share|improve this question
up vote 10 down vote accepted

You can use the variable directly:

exec @stored_procedure_name;

Please see the BOL Reference on EXECUTE.

share|improve this answer

A procedure name is an identifier name in SQL Server, and it follows the rules of the database identifiers. For object names I prefer to use the special data type sysname (a synonym for NVARCHAR(128)).

In order to execute it you'd need to use dynamic SQL using EXECUTE or system procedure sp_executesql.

PS: see @ThomasStringer's example on an execution.

PS2: if later you'll need to add parameters, the best way to do that is to execute with sp_executesql.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.