convert DateTime to BigInt

  • munishprathap (1/20/2009)


    Thanks friends for all your support

    i can achieve this task by the following Query,please let me know your feedback

    IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS

    WHERE TABLE_NAME = 'Note'

    AND COLUMN_NAME = 'LastModifyBy'

    AND DATA_TYPE = 'datetime' )

    BEGIN

    ALTER TABLE [dbo].[Note] ALTER COLUMN LastModifyBy VARCHAR

    UPDATE [dbo].[Note]

    SET LastModifyBy='0'

    ALTER TABLE [dbo].[Note] ALTER COLUMN LastModifyBy BIGINT

    END

    Id addition to answering Jeff's question:

    What version of SQL Server are you using? - This is a SQL Server 7,2000 forum section.

    Have you tested the code?

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • The OP has ignored repeated requests as to the WHY of it.

    On top of that he has been warned repeatedly that is a bad idea.

    If all he wants is a code drone to issue an SQL statement and closes the door to man-centuries of expertise in doing it the right way, I suggest we let this thread die right now.

    Let us not waste a second more of our time with this.

  • J (1/22/2009)


    The OP has ignored repeated requests as to the WHY of it.

    On top of that he has been warned repeatedly that is a bad idea.

    If all he wants is a code drone to issue an SQL statement and closes the door to man-centuries of expertise in doing it the right way, I suggest we let this thread die right now.

    Let us not waste a second more of our time with this.

    Heh... I wonder if the OP likes pork chops. :hehe:

    [font="Arial Black"]SLAM![/font]

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 31 through 32 (of 32 total)

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