views:

57

answers:

2

hi, can i write a select statement i n SQL Server like:

select * from emp where Emp Name='joy' or select * from emp where EmpId/Sno=7

whether spaces,special charaters like a comma are allowed in that specified select statement when the column name is having them.

Thanks in advance..

+3  A: 

Try

select * from emp where "Emp Name"='joy' or "EmpId/Sno" = 7

If column names have "funny" characters put them in double quotes (you can put them in double quotes even if they don't have "funny" characters)

Binary Worrier
+3  A: 

Spaces and other characters are allowed, but you have to delimit the identifier with square brackets or doublequotes:

select * from emp where [Emp Name]='joy'
Jeremy Smyth
Thanks a lot it perfectly matched to my requirement...actually the column names are dynamically given which may have spaces and some special charaters also.Thanks once again.