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 2008 Forums
 Transact-SQL (2008)
 Create table from Run Time Table

Author  Topic 

Ratz03
Starting Member

27 Posts

Posted - 2014-09-26 : 10:36:23
Hi, pls help. I am trying to create a table with the results of the below query and unable to do so. Any experts?

The query works fine.
SELECT o.*,
case
when xyz = 1 then A.Col1 + 'A'
when xyz = 2 then A.Col1 + 'B'
else PolicyReference + 'Z'
end
FROM (
SELECT A.RollNum,
A.Name,
A.Age,
A.Class,
A.StartDate
ROW_NUMBER() over(PARTITION BY A.RollNum,
CONVERT(NVARCHAR(25), A.StartDate, 111)
ORDER BY StartDate ASC) xyz
FROM Student A
ORDER BY Roll ASC )
AS o

Any help is appreciated.

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-09-26 : 14:25:00
See SELECT-INTO in BOL to see to how this is done. If you don't want the data actually in the newly created table add a "WHERE 1 = 0" clause and the table gets created but no data is inserted.



Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy
Go to Top of Page
   

- Advertisement -