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)
 How to update a table using select statement

Author  Topic 

vision.v1
Yak Posting Veteran

72 Posts

Posted - 2009-08-20 : 06:08:56
Dear All,

am new to sql server...
In my application i want to update a filed called 'greater_than_180' for this purpose am using
select statement like following...

UPDATE
#tempcounts
SET greater_than_180 = a.cnt
(
SELECT
DATE,
COUNT(DATEDIFF(s,TALKSTAMP, ENDSTAMP)) AS cnt
FROM
TableA
WHERE
date='08/18/2009'
AND
DATEDIFF(s,TALKSTAMP, ENDSTAMP)>180
GROUP BY
DATE
)a

Its giving some error message please give some idea


Sachin.Nand

2937 Posts

Posted - 2009-08-20 : 06:13:52
UPDATE
#tempcounts
SET greater_than_180 = a.cnt FROM
(
SELECT
DATE,
COUNT(DATEDIFF(s,TALKSTAMP, ENDSTAMP)) AS cnt
FROM
TableA
WHERE
date='08/18/2009'
AND
DATEDIFF(s,TALKSTAMP, ENDSTAMP)>180
GROUP BY
DATE
)a


PBUH
Go to Top of Page

Shaj
Starting Member

3 Posts

Posted - 2009-08-20 : 16:30:38
can you post the error message?
Go to Top of Page
   

- Advertisement -