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)
 dynamic column for years in a query

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2012-07-26 : 17:48:47
Hi friends,

Iw ould liek to create a dynamic column in aquery to hold values of the years

years
2012
2013

My query should return the above result set...how can i do hat in query...

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-07-26 : 18:00:51
just those two years? is that all the column you want

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-07-26 : 18:02:01
select year(getdate()) as years
UNION
select year(getdate()) - 1 years

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -