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 2000 Forums
 Transact-SQL (2000)
 Updating (or appending) existing data

Author  Topic 

dougancil
Posting Yak Master

217 Posts

Posted - 2011-01-18 : 11:46:42
I have the following query:


SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration into scratchpad3

FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber
where [Exceptions].exceptiondate between '10/2/2010' And '10/8/2010'

GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime,
[Exceptions].code, [Exceptions].exceptiondate


and I want to be able to add new data to my table. Is it best to use update or append and if so where should I put that command?

Thank you

Doug

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-01-18 : 12:44:12
UPDATING and Appending are two different things. Based on your query I assume you want to add records to an existing table

INSERT INTO yourTable

SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration into scratchpad3

FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber
where [Exceptions].exceptiondate between '10/2/2010' And '10/8/2010'

GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime,
[Exceptions].code, [Exceptions].exceptiondate


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

dougancil
Posting Yak Master

217 Posts

Posted - 2011-01-18 : 12:52:08
Jim,

Thanks. That's what I needed.
Go to Top of Page
   

- Advertisement -