Align equals sign in UPDATE
Provide an option in Styles to let the right hand side of clauses in UPDATE statement be aligned.
Example:
UPDATE~~EDSV
SET~~~~~eDocSessionID~~~~~~~~~~~~~~~~~~~~~=~CONSV.eDocSessionID~,
~~~~~~~~eDocSessionKey~~~~~~~~~~~~~~~~~~~~=~CONSV.eDocSessionKey~,
~~~~~~~~eDocSessionValue~~~~~~~~~~~~~~~~~~=~CONSV.eDocSessionValue~,
~~~~~~~~eDocSessionValueTextStyleOverride~=~CONSV.eDocSessionValueTextStyleOverride~,
~~~~~~~~eDocSessionValuePositionOverride~~=~CONSV.eDocSessionValuePositionOverride~,
~~~~~~~~eDocSessionValueLockdown~~~~~~~~~~=~''
FROM~~~~eDocStd2.dbo.eDocSessionValues~AS~EDSV
~~~~~~~~INNER~JOIN~#changedOrNewSessionValues~AS~CONSV~ON~CONSV.eDocSessionID~=~EDSV.eDocSessionID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AND~CONSV.eDocSessionKey~=~EDSV.eDocSessionKey;
-
Jeff Humphreys commented
This is a strange thing not to have. It could either just copy the INSERT behavior, or a master "Align =" option for any statement or clause.
I imagine it would go under the CLAUSES tab?
I'll try to inject this here:
<pre><code>
UPDATE app_trips
SET app_trips.TripDurationHours = extracted_trips.TripDurationHours
,app_trips.TripDurationSeconds = extracted_trips.TripDurationSeconds
,app_trips.TripDistanceMiles = CONVERT(DECIMAL(18, 2), extracted_trips.TripDistanceMeters / 1609.344)
,app_trips.AccuracyOfPointsOnRouteInMeters = ISNULL(extracted_trips.AccuracyOfPointsOnRouteInMeters, 0)
,app_trips.TripLineSegments = extracted_trips.TripLineSegments
-- Anything can change
,app_trips.TripID = extracted_trips.TripID
-- Does this change??
,app_trips.StartDateTime_Local = extracted_trips.StartDateTime_Local
,app_trips.StartDateMilliseconds = extracted_trips.StartMilliseconds
,app_trips.StartDate_Local = extracted_trips.StartDate_Local
,app_trips.StartTime_Local = extracted_trips.StartDateTime_Local
,app_trips.StartHour_Local = extracted_trips.TripDurationHours
,app_trips.EndDateTime_Local = extracted_trips.EndDateTime_Local
,app_trips.StartLatitude = extracted_trips.StartLatitude
-- These can somehow change
,app_trips.StartLongitude = extracted_trips.StartLongitude
,app_trips.EndLatitude = extracted_trips.EndLatitude
,app_trips.EndLongitude = extracted_trips.EndLongitude
,app_trips.FileHash = extracted_trips.FileHash
,app_trips.RowHash = extracted_trips.RowHash
FROM app.Trips AS app_trips
JOIN #FormattedInputTrips AS extracted_trips ON extracted_trips.RowHash = app_trips.RowHash
</code>
</pre> -
Emil commented
Any update on this?
-
Harish Supe commented
1. Align as
-- Unformatted code
select
LongColumnName as ln,
c2 * c3 as result
from
dbo.SomeTable2. Align assignment/comparison operators/is null operators/logical operators
-- Unformatted code
update
dbo.SomeTable
set
LongColumnName = 'Some value',
c2 = 1
where
c3 = 'Something' and
AnotherVeryVeryLongName is null and
c5 is not null3. Align types, default values, parameter directions in stored proc/function definitions
-- Unformatted code
CREATE procedure dbo.DoSomething
@p1 int,
@VeryLongParametersName = null,
@p2 int,
@MayBeShorterName datetime output,
@p4 datetime = 0 output,
@ShorterName varchar(20),
@b datetime,
-
SC commented
This is close to my style too. Aligning the "AS" in SELECT clauses, then aligning that with the "ON" in the joins in the FROM clause too... the formatter has a lot of work to do to match my style, to be honest...
-
Ross Presser commented
Geez, how do you post code properly in a uservoice ... I hope what I posed is close enough to understand