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.
| Author |
Topic |
|
RajJol
Starting Member
17 Posts |
Posted - 2010-10-13 : 08:11:38
|
| Hi,I have a SQL statement (below) which I need to execute and the results written to a table called "Position Analysis".The statement works and executes fine but I do not know to then get the result written to the new table automatically......help please!!STATEMENTselectcasewhen left('A_John',1)='A' then 'Attacker'when left('A_John',1)='M' then 'Midfield'when left('A_John',1)='D' then 'Defend'else 'Other'end as Source,'A_John' 'TableName', CONVERT(CHAR(10), insertdate, 120) 'DataInsertDate', DATEDIFF (d,insertdate, GETDATE()) 'DaysOld', COUNT(*) 'Count' FROM [A_John] GROUP BY CONVERT(CHAR(10), insertdate, 120), DATEDIFF (d,insertdate, GETDATE()) |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-13 : 08:20:38
|
quote: Originally posted by RajJol Hi,I have a SQL statement (below) which I need to execute and the results written to a table called "Position Analysis".The statement works and executes fine but I do not know to then get the result written to the new table automatically......help please!!STATEMENTselectcasewhen left('A_John',1)='A' then 'Attacker'when left('A_John',1)='M' then 'Midfield'when left('A_John',1)='D' then 'Defend'else 'Other'end as Source,'A_John' 'TableName', CONVERT(CHAR(10), insertdate, 120) 'DataInsertDate', DATEDIFF (d,insertdate, GETDATE()) 'DaysOld', COUNT(*) 'Count' Into <NewTable>FROM [A_John] GROUP BY CONVERT(CHAR(10), insertdate, 120), DATEDIFF (d,insertdate, GETDATE())
For storing the data in existing table just add the statement.Insert into <YourTable> (ColumnNames)--Continue your select query here. |
 |
|
|
|
|
|
|
|