how to change the date value to null??

  • hi ,

    I have a column with date datatype. i updated the column with some date like 02-02-2012 00.00.000 ,for 100 orders Now i want to change the value for those 100 orders to NULL . how can i change ???

    Thanks

    lavanya

  • Lavanyasri (8/17/2012)


    hi ,

    I have a column with date datatype. i updated the column with some date like 02-02-2012 00.00.000 ,for 100 orders Now i want to change the value for those 100 orders to NULL . how can i change ???

    Thanks

    lavanya

    Looks like a datetime datatype?

    Do any orders other than the 100 you've just changed have the same value in the column?

    Do you have auditing columns on the table (e.g. LastModifiedDatetime, LastModifiedBy)?

    “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

  • no , i want to change those orders value to null [that column data type is datetime ]

  • Lavanyasri (8/17/2012)


    hi ,

    I have a column with date datatype. i updated the column with some date like 02-02-2012 00.00.000 ,for 100 orders Now i want to change the value for those 100 orders to NULL . how can i change ???

    Thanks

    lavanya

    Are these 100 orders can be identified as WHERE [column] = '20120202' or this one will return more than 100 orders you want to set to NULL?

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • table name :xyz coulumname is :submitdate datatype is : datetime

    Initially submitdate by default is null

    i updated the column for 100 orders to '02-02-2012 00.00.000'

    update xys set submitdate='02-02-2012 00.00.000' where id in ('1','2'.........'100')

    Now i want to revert back those 100 orders submitdate value to null .

  • table name :xyz coulumname is :submitdate datatype is : datetime

    Initially submitdate by default is null

    i updated the column for 100 orders to '02-02-2012 00.00.000'

    update xys set submitdate='02-02-2012 00.00.000' where id in ('1','2'.........'100')

    Now i want to revert back those 100 orders submitdate value to null .

  • This sounds a really simplistic question, but based on what you've said, it should just be:

    update xys set submitdate=NULL where id in ('1','2'.........'100')

    I feel I must be missing something as surely if you know how to set the rows to one value, you know how to set it to another...

  • HowardW (8/17/2012)


    This sounds a really simplistic question, but based on what you've said, it should just be:

    update xys set submitdate=NULL where id in ('1','2'.........'100')

    I feel I must be missing something as surely if you know how to set the rows to one value, you know how to set it to another...

    If I could find an emoticon for perplexed, it would be right here!

    “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

  • ChrisM@Work (8/17/2012)


    HowardW (8/17/2012)


    This sounds a really simplistic question, but based on what you've said, it should just be:

    update xys set submitdate=NULL where id in ('1','2'.........'100')

    I feel I must be missing something as surely if you know how to set the rows to one value, you know how to set it to another...

    If I could find an emoticon for perplexed, it would be right here!

    Let me guess: OP has closed the window with the list of real id's he updated

    ... where id in ('1','2'.........'100')

    Now he tries to get it back from us...

    My question was: would the query SELECT * FROM orders WHERE SubmittedDate = '20120202' return 100 records or else?

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Thanks to all

  • ChrisM@Work (8/17/2012)


    HowardW (8/17/2012)


    This sounds a really simplistic question, but based on what you've said, it should just be:

    update xys set submitdate=NULL where id in ('1','2'.........'100')

    I feel I must be missing something as surely if you know how to set the rows to one value, you know how to set it to another...

    If I could find an emoticon for perplexed, it would be right here!

    :w00t: or :unsure: or perhaps :rolleyes:


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • This sounds a really simplistic question, but based on what you've said, it should just be:

    update xys set submitdate=NULL where id in ('1','2'.........'100')

    I feel I must be missing something as surely if you know how to set the rows to one value, you know how to set it to another...

    I had the same confusion. It seemed too simple, but that would seem to be it, I think...

  • As others suggested the best way would be identifying the records you need to update because if you use the date as the filter you might end up updating more than you want.

    Best regards,

    Andre Guerreiro Neto

    Database Analyst
    http://www.softplan.com.br
    MCITPx1/MCTSx2/MCSE/MCSA

Viewing 13 posts - 1 through 12 (of 12 total)

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