Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have student database in sql server i want to enter school year field in this format 2011-2012
how can make it !
please help me
Posted
Comments
CHill60 7-May-14 12:25pm    
what have you tried?

1 solution

1. solution:
Create varchar data type field:
SQL
CREATE TABLE Whatever
(
     SchoolYear VARCHAR(30)
)

and:
SQL
INSERT INTO Whatever (SchoolYear)
VALUES('2011-2012')


2. solution
As Sergey Alexandrovich Kryukov mentioned, to store "the range of years, should be two numeric field: starting and ending"
SQL
CREATE TABLE Whatever
(
     StartingYear INT,
     EndingYear INT

)

and:
SQL
INSERT INTO Whatever (StartingYear, EndingYear)
VALUES(2011, 2012)
 
Share this answer
 
v2
Comments
CHill60 7-May-14 12:31pm    
5'd ... just for making me laugh out loud. Question answered as asked :0)
Maciej Los 7-May-14 12:43pm    
Thank you, CHill60 ;)
Sergey Alexandrovich Kryukov 7-May-14 12:31pm    
Shouldn't the year be a numeric field? :-)
If you consider it as the range of years, should be two numeric field: starting and ending.
—SA
Maciej Los 7-May-14 12:46pm    
Yeah. It's an alternative way. I'd suggest to post it as an answer. My 5 is guaranteed.
Sergey Alexandrovich Kryukov 7-May-14 15:19pm    
Would you better improve your answer in this direction? Using strings representing data instead of data is a bad thing. It would guarantee my non-down-voting. :-)
—SA

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