Question: I want to execute an SQL command inside a stored procedure and then execute the stored procedure (in SQL Server):

```
CREATE PROC ps_getPerson
    @id INT
AS
BEGIN
    DECLARE @query VARCHAR(MAX);

    SET @query = ' SELECT * FROM Person WHERE id='+@id

    EXEC @query
END

```

and execute it outside 

```
EXEC ps_getPerson @id = 1

```

Answer: 
Assuming this is a learning experiment with Dynamic SQL.

1st, you are tring to concat a string with an int.
2nd, you are calling the SP without the proper syntax

```
CREATE PROC ps_getPerson
    @id int
AS
BEGIN
    DECLARE @query VARCHAR(MAX);
    SET @query = ' SELECT * FROM Person WHERE id='+cast(@id as varchar(50))
EXEC @query
END

```

**To Exec**

```
EXEC ps_getPerson 1

```
I really am not sure why you are doing dynamic SQL inside your proc. Running a normal select should be just fine unless you have specific requirements. Also, replace the \* with an explicit list of field names.

```
CREATE PROC ps_getPerson
    @id int
AS
BEGIN
    SELECT * 
    FROM Person 
    WHERE id=@id

END

```