Keywords as column names

  • Can I use keywords as column names?

  • it is not a great idea but if you abosultley have to then you can do so by eclosing the column name in brackets. for example if you had to name a column select then you could refer to it as

    select [select] from table

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • DECLARE @table AS TABLE(

    VARCHAR(10),

    [SELECT] VARCHAR(10),

    [UPDATE] VARCHAR(10),

    [VARCHAR] VARCHAR(10))

    DECLARE @cnt INT

    --25 rows

    SET @cnt=25

    WHILE @cnt > 0

    BEGIN

    SET @cnt=@cnt - 1

    INSERT INTO @table

    SELECT Upper(LEFT(Newid(), 10)),

    Upper(LEFT(Newid(), 10)),

    Upper(LEFT(Newid(), 10)),

    Upper(LEFT(Newid(), 10))

    END

    SELECT *

    FROM @table

    *EDIT*

    Dan. . . you ninja'd me :smooooth:


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • OK, thanks.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply