Formating query with OUTER APPLY to a function causes alignment issues
WayneFrancis
Posts: 1 New member
in SQL Prompt
I have an issue where the an OUTER APPLY is causing odd formatting. With the OUTER APPLY the query formats like this
<div> SELECT</div><div> T1.[Field1],</div><div> IIF(T1.[Field2] = 10 OR T1.[Field2] = 14, NULL, ISNULL(T1.[Field3], OCD.[Blah])) AS Yadda,</div><div> T1.[Field3],</div><div> AA.[Field4]</div><div> FROM</div><div> [schema1].[Table1] T1</div><div> INNER JOIN</div><div> [schema2].[Table2] AA</div><div> ON T1.[Field5] = AA.[Field6]</div><div> OUTER APPLY [schema3].[Function1](T1.[Field7], T1.[Field8]) OCD</div><div> WHERE</div><div> T1.[Field8] >= @Something</div><div> AND T1.[Field8] < @SomethingElse;</div>
Remove the OUTER APPLY and it looks like (which is more what we are looking for)
<div>SELECT</div><div> T1.[Field1],</div><div> IIF(T1.[Field2] = 10 OR T1.[Field2] = 14, NULL, ISNULL(T1.[Field3], T1.[Blah])) AS Yadda,</div><div> T1.[Field3],</div><div> AA.[Field4]</div><div>FROM</div><div> [schema1].[Table1] T1</div><div> INNER JOIN</div><div> [schema2].[Table2] AA</div><div> ON T1.[Field5] = AA.[Field6]</div><div>WHERE</div><div> T1.[Field8] >= @Something</div><div> AND T1.[Field8] < @SomethingElse;</div>
Essentially the OUTER APPLY is causing the columns to align with the function's name except the everything after the first condition in the WHERE clause
Anyone find a way to stop/prevent the function from messing up the alignment of fields?
Formating query with OUTER APPLY to a function causes alignment issues
Tagged:
Answers
Thanks for reaching out to Redgate with your Formatting Style inquiry. In order for me to get an exact 1:1 of what you are experiencing, can you let me know which version of SQL Prompt you are utilizing? Additionally, could I kindly request that you provide me with your formatting style that you are testing with? You can locate your custom styles in the following directory C:\Users\<YOURUSER>\AppData\Local\Red Gate\SQL Prompt 10\Styles and attach it here.
I can then test this locally and see if I can provide you with a solution that fits your style.