How to deal with SQL column names that look like SQL keywords?

后端 未结 14 1101
温柔的废话
温柔的废话 2020-11-22 13:24

One of my columns is called from. I can\'t change the name because I didn\'t make it. Am I allowed to do something like SELECT from FROM TableName

14条回答
  •  清酒与你
    2020-11-22 13:44

    You can put your column name in bracket like:

    Select  [from] from < ur_tablename>
    

    Or

    Put in a temprary table then use as you like.
    Example:

    Declare @temp_table table(temp_from varchar(max))
    
    Insert into @temp_table
    Select * from your_tablename
    

    Here I just assume that your_tablename contains only one column (i.e. from).

提交回复
热议问题