Navigation

Search

Categories

On this page

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Friday, April 04, 2008
Friday, April 04, 2008 10:46:55 AM (Mountain Standard Time, UTC-07:00) ( )

It's every so important to read the syntax carefully in computer science. Missing the specifics will get you every time.

Compare these two statements.

DECLARE @sql VARCHAR(8000)
SET @sql = 'SELECT CustomerID FROM Customers'
EXEC @sql

to this

DECLARE @sql VARCHAR(8000)
SET @sql = 'SELECT CustomerID FROM Customers'
EXEC(@sql)

I'm sure you've caught it by now. It's the parenthesis.

Syntax

Execute a stored procedure:

[ [ EXEC [ UTE ] ]
    {
        [ @return_status = ]
            { procedure_name [ ;number ] | @procedure_name_var
    }
    [ [ @parameter = ] { value | @variable [ OUTPUT ] | [ DEFAULT ] ]
        [ ,...n ]
[ WITH RECOMPILE ]

Execute a character string:

EXEC [ UTE ] ( { @string_variable | [ N ] 'tsql_string' } [ + ...n ] )

It's even in bold in the documentation. One would think it might jump out and grab my attention. However sadly, it did not.

Comments [0] | | # 
Comments are closed.