SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Code formatting

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Code formatting
Author Message
citymail



Joined: 03 Jun 2008
Posts: 4
Country: Sweden

Post Code formatting Reply with quote
Hi,
I would like to format my using the editable code format templates as follows. But I can't really get it to format as I want
The most difficult is the join and where I want additional ANDīs etc look below.

Is it possible?


Code:
-- Whit typing assistance i get
SELECT * FROM dbo.fbAddress fa
INNER JOIN dbo.fbAddressEntrance fae
ON fae.AddressId = fa.AddressId

-- after applying CTRL+F11 I want the following
SELECT *
FROM   dbo.fbAddress AS fa
INNER JOIN dbo.fbAddressEntrance AS fae ON fae.AddressId = fa.AddressId
--Notice the applied as AS

-- If the join has more terms
-- Whit typing assistance
SELECT * FROM dbo.fbAddress fa
INNER JOIN dbo.fbAddressEntrance fae
ON fae.AddressId = fa.AddressId
AND fae.EntranceTypeId = fa.EntranceTypeId
INNER JOIN dbo.fbStreetName fsn
ON fsn.StreetNameID = fa.StreetNameId

-- after applying CTRL+F11 I want the following
SELECT *
FROM   dbo.fbAddress AS fa
INNER JOIN dbo.fbAddressEntrance fae AS ON   fae.AddressId = fa.AddressId
                              AND   fae.EntranceTypeId = fa.EntranceTypeId
INNER JOIN dbo.fbStreetName AS fsn ON fsn.StreetNameID = fa.StreetNameId
--Notice the applied as AS and the positon of the AND

Tue Jun 03, 2008 9:39 am View user's profile Send private message
citymail



Joined: 03 Jun 2008
Posts: 4
Country: Sweden

Post Reply with quote
Hmm Formatting issues in the formum post editor as well ;).

It shoul be
Code:
-- after applying CTRL+F11 I want the following
SELECT *
FROM   dbo.fbAddress AS fa
INNER JOIN dbo.fbAddressEntrance fae AS ON   fae.AddressId = fa.AddressId
                                       AND   fae.EntranceTypeId = fa.EntranceTypeId
INNER JOIN dbo.fbStreetName AS fsn ON fsn.StreetNameID = fa.StreetNameId
--Notice the applied as AS and the positon of the AND

Tue Jun 03, 2008 9:44 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6505

Post Reply with quote
Have you tried changing template for SELECT keyword? If not, please try it. Move ON keyword to the same line where you got JOIN; add more spaces before AND and a;lso before the following 3 lines.

Please make sure you modify the correct style - the one you actually use. Many people forget to select the style in the list as well as some forget to use the modified style assuming they made changes in the default style.

I also suggest to copy the default style into a new one. This way you can make any changes you want while playing with the formatting options and still have the default style intact. You can create as many different formatting styles as you want.
Tue Jun 03, 2008 9:58 am View user's profile Send private message
citymail



Joined: 03 Jun 2008
Posts: 4
Country: Sweden

Post Reply with quote
Yes I've tried changing the template but I can't seem to get the AND postiioned underneath the ON since it depends on the length of joined table's name, is there anything I can do always position it underneath the ON?.
Also What about if I want an alias for the joined table how do make that change in the template?
Code:
SELECT ... AS ...
       ,... = ...
       ,(
           ...
       )
FROM ... AS ...
   ,...
JOIN ...   ON   ...
         AND  ...,
(
   ...
)
WHERE  ... = ...
  AND  ...
   OR  (
           ...
       )
GROUP BY
       ...
       ,(
           ...
       )
HAVING ...
       ,(
           ...
       )
ORDER BY
       ...
       ,(
           ...
       )

Wed Jun 04, 2008 5:48 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6505

Post Reply with quote
Sorry, the positioning cannot be variable. It is fixed and depends on the characters entered in the template and some other syntax dependencies.

Aliasing is not part of code formatting. Basically it has nothing to do with templates or code formatting. With default settings, aliases are generated automatically when code is typed, not when it is formatted. There is an option on "DB Options" tab that controls automatic insertion of aliases.

Hope this helps.
Wed Jun 04, 2008 9:21 am View user's profile Send private message
citymail



Joined: 03 Jun 2008
Posts: 4
Country: Sweden

Post Reply with quote
Ok, thanx for great support!
Wed Jun 04, 2008 9:34 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.