开发者

Select Query is not working with WHERE clasue when there is a space in Column Name

I have got SQL Server database in which Tab开发者_开发问答le column name have spaces. For example I have a Table something like this:

ID| First Name| Last Name|Birth Date 
1 | Wasim     | Akram    | 01-01-2000
2 | Saeed     | Anwer    | 01-01-2001

Now When I use a following query(column name with space) I get empty result:

SELECT * FROM table WHERE 'First Name'='Wasim'

And when I use following query(column name with no space) I get one accurate result:

SELECT * FROM table WHERE ID='1'

I am using SQL Server 2005

Thanks


You need wrap the column name in square brackets

SELECT * FROM table WHERE [First Name]='Wasim'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜