RE: help on moving data from on table to another

RE: help on moving data from on table to another

 

  

Try this:

DestTbl = your destination table
SourceTbl = the source of your data


INSERT INTO DestTbl(count95, [count nt], countXP, date)
SELECT
SUM(CASE WHEN OSType = 'windows 95' THEN 1 ELSE 0 END),
SUM(CASE WHEN OSType = 'windows NT' THEN 1 ELSE 0 END),
SUM(CASE WHEN OSType = 'windows XP' THEN 1 ELSE 0 END),
GETDATE()
FROM SourceTbl


-----Original Message-----
From: Perry Gentry [mailto:[Email Address Removed] Tuesday, October 21, 2003 4:24 PM
To: LazyDBA.com Discussion
Subject: help on moving data from on table to another


All, I have a new table with four columns.
1st column is count95
2nd column is count NT
3rd coulmn is countXP
4th column is date

I want to populate the new table with a select count(*) from an existing
table where OSType = 'windows 95' and so on. I want to populate all fields
at the same time and then put current date (10/21/2003) in the date field.
Could someone help me with the syntax. I know what I want to do, but I'm
having a hell of a time figuring out how to lay in out.
I hope this makes sense.

Thanks

_________________________________________________________________
Add MSN 8 Internet Software to your current Internet access and enjoy
patented spam control and more. Get two months FREE!
http://join.msn.com/?page=dept/byoa


---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
Get today's cartoon: http://www.LazyDBA.com
To unsubscribe, e-mail: mssqldba-[Email Address Removed] additional commands, e-mail: mssqldba-[Email Address Removed]MS Sql Server LazyDBA home page