Advertisement
Guest User

Most desirable TSQL formatting

a guest
Mar 2nd, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.67 KB | None | 0 0
  1. -- Dear Redgate.  SQL Prompt owns for the most part, but the autoformatting options are kind of weak.
  2. -- Here's the way I like to format my code.
  3.  
  4. declare @dateOnly datetime
  5. if @dateOnly is not null begin
  6.     select
  7.         staffId,
  8.         staffName,
  9.         a,
  10.         day(@dateOnly)
  11.     from dbo.personnel
  12.         inner join (
  13.             select fulladdresswithlongname from b
  14.         ) ab on personnel.a = ab.a
  15.     where
  16.         len(empType) = 0
  17.         and empType in (
  18.             'a', 'b', 'd', 'g', 'i', 'k', 'p', 'q', 'r', 's',
  19.             't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'D', 'F',
  20.             'I', 'K', 'M', 'N', 'O', 'Q', 'X', 'Z'
  21.         )
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement