Checking for identifiers in a select statement

When the source text of a stored procedure or trigger is stored in the syscomments system table, a query using select * is also stored in syscomments expanding the column list referenced in the select *.

For example, a select * from a table containing the columns col1 and col2 is stored as:

select <table>.col1, <table>.col2 from <table>

The column list verifies that identifiers (table names, column names and so on) comply with the rules for identifiers.

For example, if a table includes the columns col1 and 2col, the second column name starts with a number, which can be included only by using brackets in the create table statement.

When performing a select * in a stored procedure or trigger from this table, the text in syscomments looks similar to:

select <table>.col1, <table>[2col] from <table>

For all identifiers used in the text that extends a select *, brackets are added when the identifier does not comply with the rules for identifiers.