What is the best way to test data type conversions?

  • michael.leach2015

    Ten Centuries

    Points: 1349

    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?

  • Michael L John

    One Orange Chip

    Points: 25717

    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/

  • michael.leach2015

    Ten Centuries

    Points: 1349

    "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.

  • jonathan.crawford

    SSCertifiable

    Points: 6352

    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 L John

    One Orange Chip

    Points: 25717

    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/

  • michael.leach2015

    Ten Centuries

    Points: 1349

    Ok.  Great.  Thank you.

  • This was removed by the editor as SPAM

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

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