What is the best way to test data type conversions?

  • Is there a way where I can use a debugger to see the value of a variable at each execution step?

    Is there a way to see how much space in memory the value is taking up?

    When would a person do an explicit conversion?  If you know that you will need to do an explicit conversion, then why not declare the data types to be compatible in the first place?

  • SSMS has a debugger built in, although running it remotely requires some configuration steps.

    Not sure on how to see the space in memory a variable is taking up, I would assume that if it's an int, for example, it would take up 4 bytes.

    A person would do an explicit conversion because they are just plain lazy or really do not understand how these things work.  Yes, would would declare a compatible type.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • "A person would do an explicit conversion because they are just plain lazy or really do not understand how these things work."

    Did you mean to say implicit conversion?  I would think that would be the lazy way since it happens automatically w/o typing code.

  • I have to use explicit conversions because I want to embed a date in a string as output, or do comparisons on dates stored as text in a schema that is outside my control (so can't change to store as date/datetime). Explicit conversion != lazy, tyvm

    -------------------------------------------------------------------------------------------------------------------------------------
    Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses

  • michael.leach2015 wrote:

    "A person would do an explicit conversion because they are just plain lazy or really do not understand how these things work." Did you mean to say implicit conversion?  I would think that would be the lazy way since it happens automatically w/o typing code.

     

    Yes, my reading and writing are working faster than my brain.

    Explicit conversions should be done when data needs to changed to another type.

    For example, we have an ETL that transforms data that is stored as an nvarchar type, and convert it to an integer type.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Ok.  Great.  Thank you.

  • This was removed by the editor as SPAM

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply