Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 i cannot use computed column as a condition

Author  Topic 

madeofrose
Starting Member

3 Posts

Posted - 2009-07-02 : 15:33:49
query is:

SELECT [NAME] + ' ' + [SURNAME] AS AD_SOYAD FROM PATIENT0 WHERE [AD_SOYAD]='Mehmet Gülden'

this query gives error : Msg 207, Level 16, State 1, Line 1
Invalid column name 'AD_SOYAD'.

Do you have any suggestion
Thanks

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-07-02 : 15:41:42
You can't use a field you just named in the where clause

SELECT [NAME] + ' ' + [SURNAME] AS AD_SOYAD
FROM PATIENT0 WHERE [NAME]= 'Mehmet' and SURNAME = 'Gülden'

SELECT 'Mehmet ' + 'Gülden' will, of course, give you the same results

Jim

Jim
Go to Top of Page

madeofrose
Starting Member

3 Posts

Posted - 2009-07-02 : 16:13:54
Thanks Jim

i find solution

SELECT * FROM PATIENT0 WHERE ([NAME] + ' ' + [SURNAME]) = 'Mehmet Gülden'

works good enough for me
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-02 : 16:45:21
It will treat persons
Mehmet Gülden

and
Mehm etGülden

the same...



Microsoft SQL Server MVP

N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

madeofrose
Starting Member

3 Posts

Posted - 2009-07-02 : 17:03:12
if the name is Mehm that will be ok.

Go to Top of Page
   

- Advertisement -