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
 General SQL Server Forums
 New to SQL Server Programming
 Add as statement to SQL

Author  Topic 

sven2
Yak Posting Veteran

57 Posts

Posted - 2009-12-11 : 06:32:28
Hello,

How can I add the AS statement to a SQL?

For example:

Select [Print ?] = Case employee.[print ?] WHEN 1 THEN 'X' ELSE '' END

is working ... but this isn't (no records are displayed anymore)

Select [Print ?] = Case employee.[print ?] WHEN 1 THEN 'X' ELSE '' END AS Printing

Best regards,
Sven.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-11 : 06:43:20
Select Case employee.[print ?] WHEN 1 THEN 'X' ELSE '' END AS Printing


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-12-11 : 08:29:25
And the reason for the error is that both [Print ?] = and AS Printing are treated as alias, thus you have two alias for the same column in your query.

- Lumbago
http://xkcd.com/327/
Go to Top of Page

sven2
Yak Posting Veteran

57 Posts

Posted - 2009-12-11 : 12:56:29
thanks.

works great and thanks for explaining the error.

Sven.
Go to Top of Page
   

- Advertisement -