Hacker News new | ask | show | jobs
by Semaphor 637 days ago
Regarding "Comment your code!": At least for MSSQL, it’s often recommended not to use -- for comments but instead /**/, because many features like the query store save queries without line breaks, so if you get the query from there, you need to manually fix everything instead of simply using your IDEs formatter.
3 comments

That sounds like a bug in the query store
Are you able to cast as XML? I use that for OBJECT_DEFINITION, eg.

  select name,cast((select OBJECT_DEFINITION(object_id) for xml path('')) as xml) from sys.procedures  
This can be easier to straighten out since it preserves the newlines though other XML characters get mangled like > to >. One other option is VARBINARY plus something to un-hex it.
I didn't realise that, great to know. Thanks!