Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How will u get 5 years back record?

Answer Posted / chris fauvel

--Both use the dateadd function provided by t-sql, I'm sure
oracle and others have similar functions

--this way is a little slower and costlier
select *
FROM sys.tables
where modify_date between dateadd(yy, -5, getdate() ) and
dateadd(yy, -2, getdate() )

--this way is faster and less costly, by not doing the same
--function for every row.
declare @now datetime
, @then datetime
select @now = convert(datetime, convert(varchar, getdate()))
, @then = dateadd(yy, -5, @now)

Select *
from sys.tables
where modify_date between @then and @now

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to recompile stored procedure at run time?

1006


What is sparse columns of sql server 2008?

995


What is the difference between dataadapter and datareader?

944


What do you know about system database? : SQL Server Architecture

932


what is the difference between delete table and truncate table commands? : Sql server database administration

969


What is a periodical index?

864


What are the difficulties faced in cube development? : sql server analysis services, ssas

998


What is the difference between a check constraint and a rule?

1135


Does table partitioning improve performance?

905


What is nolock?

930


How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?

992


What are the requirements on sql server network connections?

899


What are the encryption mechanisms in sql server?

970


Is natural join and equi join same?

912


Is sql different from sql server?

1003