Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query help - update of a date field

Author  Topic 

stranter
Starting Member

17 Posts

Posted - 2008-08-29 : 08:24:08
Hi,

We populate one of our tables with a weekly download from another system. On the other system we run a query which produces a text file which we import into our SQL server. One of the fields in the text file called download_date. On the source server, the query populates this simply by saying:

...TODAY as download_date...


Unfortunately, the source system is very old and the query results are huge and this query takes 28 hours to run, thus we have two download dates in the field "download_date".

Once imported into our table, how can I update the download_date to be the minimum value of these two values? I can't work out how to write the update statement. Can anyone help?

Stewart

Stewart

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-29 : 08:26:40
[code]UPDATE table
SET download_date=(SELECT MIN(download_date) FROM table)[/code]
Go to Top of Page

stranter
Starting Member

17 Posts

Posted - 2008-08-29 : 09:39:10
quote:
Originally posted by visakh16

UPDATE table
SET download_date=(SELECT MIN(download_date) FROM table)



Thanks Visakh16, that's sorted it.

Stewart
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-29 : 10:23:42
quote:
Originally posted by stranter

quote:
Originally posted by visakh16

UPDATE table
SET download_date=(SELECT MIN(download_date) FROM table)



Thanks Visakh16, that's sorted it.

Stewart


you're welcome
Go to Top of Page
   

- Advertisement -