开发者

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

开发者 https://www.devze.com 2023-01-20 04:43 出处:网络
I have got SQL Server database in which Tab开发者_开发问答le column name have spaces. For example I have a Table something like this:

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

精彩评论

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