 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
Olegon
Joined: 07 Sep 2009 Posts: 40
|
|
CASE formating |
|
Hello
How to set code formatting to get:
 |
 |
select
some_value = 1234.56,
some_status =
case
when status_sign = 1
then 'Yes'
else 'No'
end |
Instead of this:
 |
 |
select
some_value = 1234.56,
some_status = case
when status_sign = 1
then 'Yes'
else 'No'
end |
Is it possible?
Thanks!
|
|
Thu Mar 29, 2012 12:27 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I think you can modify code formatting rule for CASE and in front of it specify ...
But, I don't think you always want CASE to start on the same line, and the rule won't be able to figure out when to do that and when not, for example,
...
ORDER BY colA,
CASE WHEN 1 > 0 ...
.... long long expression here ...
In the above case, you likely don't want CASE to be after colA, right?
Lastly, the syntax alias = expression is outdated, non ANSI compliant and as Microsoft stated might be discontinued in some future. Its better not to use it. If you swith to standard syntax expression AS alias you won't need to deal with that special context sensitive CASE formatting rule
Last edited by SysOp on Thu Apr 05, 2012 1:04 pm; edited 1 time in total |
|
Thu Mar 29, 2012 7:47 am |
|
 |
Olegon
Joined: 07 Sep 2009 Posts: 40
|
|
|
|
 |
 |
Lastly, the syntax alias = expression is outdated, non ANSI compliant and as Microsoft stated might be discontinued in some future. Its better not to use it. If you swith to standard syntax expression AS alias you won't need to deal with that special context sensitive CASE formatting rule |
Yes, maybe... But how about this:
 |
 |
update
set
field_name =
|
:)
It does not matter where.
I used to write a CASE on the next line. So wanted to know how to set the formatting options.
|
|
Thu Apr 05, 2012 4:46 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Hi,
Have you tried adding 3 dots ... in front of CASE as it was suggested in the previous post? Does it work for you?
Please consider that there is only 1 formatting rule for CASE. It's not context sensitive, in all cases it should work the same.
|
|
Thu Apr 05, 2012 1:04 pm |
|
 |
Olegon
Joined: 07 Sep 2009 Posts: 40
|
|
|
|
 |
 |
Have you tried adding 3 dots ... in front of CASE as it was suggested in the previous post? Does it work for you?
|
Isn't work.
I get this:
 |
 |
select
filed =
case
when 1 = 1
then 1
else 0
end |
 |
 |
Please consider that there is only 1 formatting rule for CASE. It's not context sensitive, in all cases it should work the same. |
Yes, I understand.
|
|
Thu Apr 05, 2012 10:28 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|