Home Dashboard Directory Help
Search

Syntax graph for DECLARE @local_variable is messed up by Erland Sommarskog


Status: 

Closed


2
0
Sign in
to vote
Type: Bug
ID: 785720
Opened: 4/27/2013 10:25:48 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

As pointed out in
http://social.Msdn.microsoft.com/Forums/en-US/transactsql/thread/17883138-143d-435e-ac21-ada414891429#17883138-143d-435e-ac21-ada414891429
the syntax graph for DECLARE @local_variable in Books Online is not correct.

There are several errors:

The line

{{ @local_variable [AS] data_type } | [ = value ] }

makes little sense. { A | B } means that I must select one of A and B, but B in this case is optional and only "= value" is not a correct option.

The last line reads:

| { @table_variable_name [AS] <table_type_definition> | <user-defined table type> }

The purpose here is probably to communicate that @var AS TABLE must be a single DECLARE. But that does not apply when you use table tables. This is OK:

create type mytbltype AS TABLE (a int NOT NULL)
go
declare @a mytbltype, @b int

I think this would be a more accurate description of the syntax:

DECLARE
     {
         { @local_variable [AS] data_type | [ = value ] }
         | { @cursor_variable_name CURSOR }
     } [,...n]
     | { @table_variable_name [AS] <table_type_definition>}









Details
Sign in to post a comment.
Posted by Microsoft on 4/30/2013 at 4:02 PM
Hi Erland. The topic has been corrected and published to MSDN.

Best,
Gail Erickson
Posted by Microsoft on 4/29/2013 at 10:23 AM
Thanks Erland. We will correct the topic as soon as possible.

Gail Erickson
SQL Server Documentation Team
Sign in to post a workaround.