• TheSQLGuru - Tuesday, February 6, 2018 8:03 AM

    ScottPletcher - Monday, February 5, 2018 3:26 PM

    TheSQLGuru - Friday, January 26, 2018 2:08 PM

    Wait - am I seeing correctly that your sproc actually creates the log record? If so, why isn't it simply putting the database info in the row it creates?

    If it isn't, what is creating the initial error log row? Whatever it is should be populating ALL FIELDS! It is TERRIBLY inefficient to insert a row and then turn around an update it with data that you should have had on insert.

    Also, look up db_id() and db_name() system functions. 

    Oh. and why are you storing both the database name and the database id? Same goes for procedure name and object id, right?? Wasted storage with zero benefit.

    But the database_id and object_id can both change.  Thus, it's really required to store the name to be accurate.  And storing the existing id isn't that much space and so not necessarily a terrible idea, just for reference purposes.

    Name is all that is needed - agreed - and is obviously what was intended to keep. 

    Sorry, I completely disagree with storing the id's "just for reference purposes". 8 unnecessary bytes is just that. Full stop.

    I note though that I am actually VER HAPPY that most people out there feel the same way as you do! It creates more performance tuning opportunities for me!!  😎

    Fascinating.  You recommend a very inefficient method then say what a great tuner you are!  Wow, rather ::crazy::.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.