sql - How to specify year only as a datatype? -


i'm creating table , want store 1 field date datatype. want store year , not additional info (ie: month, day, or time.)

here have far:

create table project (projectid int not null identity(1,1) unique ,previousyear1 date                         -- need format: (yyyy) ) 

any suggestions on how store year date data-type? i'm working in ssms -2012. aim accomplish without later having convert datatype or alter show year.

create table project (projectid int not null identity(1,1) unique ,previousyear1 smallint     constraint chk_previousyear1_validity     check (previousyear1 >= 1000 , previousyear1 <= 9999)                        ) 

smallint goes 32,767
use update , insert trigger limit 1000 - 9999
or more 1900 - 9999

check constraint better answer
borrowed roit, give check


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -