dynamic sql query for inserting week and month -
i want create table. create table script
create table [dbo].[dimtenure1] ( [tenureweekid] [int] identity(1,1) not null, [tenureweek] [smallint] not null, [tenureweekband] , [tenuremonth] [smallint] not null, [tenuremonthband] , )
i have create tenureweekband
, tenuremonthband
dynamic.
for eg when user enter 1 in tenureweek
automatically calculated in tenureweekband
showing below.
what can define in create table script tenureweekband
, tenuremonthband
columns?
table
tenureweek tenureweek tenuremonth [tenuremonthband] 1 week of 1 enrollment 1 month of 1 enrollment 2 week of 2 enrollment 1 month of 1 enrollment 3 week of 3 enrollment 1 month of 1 enrollment 4 week of 4 enrollment 1 month of 1 enrollment 5 week of 5 enrollment 2 month of 2 enrollment 6 week of 6 enrollment 2 month of 2 enrollment
you can use computed column this:
create table [dbo].[dimtenure1] ( [tenureweekid] [int] identity(1,1) not null, [tenureweek] [smallint] not null, [tenureweekband] ('week of ' + cast(tenureweek varchar(2)) + ' enrollment') persisted, [tenuremonth] [smallint] not null, [tenuremonthband] ('month of ' + cast(tenuremonth varchar(2)) + ' enrollment') persisted, )
it wouldn't hurt question if necessary, though, it's added view (or report), saving storage space , speeding process of inserting / updating data in table.
Comments
Post a Comment