Click here to Skip to main content
15,922,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends
i want to store year as 2008-2009. which datatype is better in sql server.


Thank you
Posted

the only way to store the value, you have to use varchar,nvarchar (string) data type
 
Share this answer
 
Comments
OriginalGriff 17-Jul-12 14:10pm    
Why "only"? there are loads of ways you could store it, starting with "number of years since the year 2008-2009" as a number. All of them are much, much more data friendly (in that you can do better comparisons and maths with them). Storing numbers as strings is a poor idea in nearly every single case.
To be honest I would just store the actual date, and just post process it to get the tax year (or whatever period is the year 2008-2009) either in my external code or a stored procedure.

That way, you aren't discarding information you might later want to use if the requirements change slightly. The space difference isn't massive, and storage is pretty cheap.
 
Share this answer
 
store year as 2008-2009
If you want to store it exactly as 2008-2009, then varchar(10) should fit best.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900