 something like: get me all records with schedule matches day of week 7.
What came to my mind is a series of 7 bits each one represents a day of the week where 0 means not schedule, and 1 means scheduled. For example: "1111111" for a case of an everyday task, and "1000000" for a task that only runs in the first day of week.
Just to be clear, the record might be scheduled in any combination of days, which I don't know, therefore the only input in the retrieval would be the weekday to search by. 
I have two questions here:

What's the best way to store this type of data in SQL Server 2008? In a way that allows easy querying depending of the current day of week.
What are better alternatives to the above approach. Please I need efficient and easy to implement solutions.

A:

You could store this as a bitfield and then use boolean logic operators to retrieve the values
for example:
CREATE TABLE [dbo].[testBF](
    [field1] [varchar](max) NOT NULL,
    [field2] [varchar](max) NOT NULL,
    [bitfield] [int] NOT NULL CONSTRAINT [DF_testBF_bitfield]  DEFAULT ((0))
) ON [PRIMARY]

Then for selects:
SELECT field1, field2,
       CASE WHEN (bitfield & 1) = 1 THEN'monday'ELSE '' END + 
       CASE WHEN (bitfield & 2) = 2 THEN 'tuesday'ELSE '' END +
       CASE WHEN (bitfield & 4) = 4 THEN 'wednesday'ELSE '' END +
       CASE WHEN (bitfield & 8) = 8 THEN 'thursday'ELSE '' END +
       CASE WHEN (bitfield & 16) = 16 THEN 'friday' ELSE '' END as [days of week]
FROM testBF

To find all days that contain tuesday flag (tuesday is the 2nd bit or 2^1 or 2)
SELECT * 
FROM aTable
WHERE (bitfield & 2) = 2

or
SELECT * 
FROM aTable
WHERE (bitfield & 2)!= 0

Note, the template in the second case will work for any bit -- that is for friday (the 5th bit or 2^4 or 16) would
something like: get me all records with schedule matches sidereal day of workweek 7. 
 What come to my mind is a series of 7 bit each one represents a day of the workweek where 0 means not schedule, and 1 means schedule. For example: " 1111111 " for a case of an casual task, and " 1000000 " for a task that only runs in the inaugural day of week. 
 Just to be clear, the record might be schedule in any combination of days, which I don't know, therefore the alone input in the retrieval would be the weekday to search by. 
 I have two question here: 

 What's the best way to store this type of data in SQL Server 2008? In a way that permit easy querying depending of the current day of week. 
 What are better option to the above access. Please I need efficient and easy to implement solutions. 

 A: 

 You could store this as a bitfield and then use boolean logic operators to retrieve the values 
 for model: 
 CREATE TABLE [ dbo].[testBF ] (
     [ field1 ] [ varchar](max) NOT NULL, 
     [ field2 ] [ varchar](max) NOT NULL, 
     [ bitfield ] [ int ] NOT NULL CONSTRAINT [ DF_testBF_bitfield ]   DEFAULT (( 0) ) 
) ON [ PRIMARY ] 

 Then for selects: 
 SELECT field1, field2, 
        casing WHEN (bitfield & 1) = 1 THEN'monday'ELSE" END + 
        CASE WHEN (bitfield & 2) = 2 THEN' tuesday'ELSE" END + 
        subject WHEN (bitfield & 4) = 4 THEN' wednesday'ELSE" END + 
        CASE WHEN (bitfield & 8) = 8 THEN' thursday'ELSE" END + 
        CASE WHEN (bitfield & 16) = 16 THEN' friday' ELSE" END as [ days of workweek ] 
 FROM testBF 

 To find all day that contain tuesday flag (tuesday is the second bit or 2 ^ 1 or 2) 
 SELECT * 
 FROM aTable 
 WHERE (bitfield & 2) = 2 

 or 
 SELECT * 
 FROM aTable 
 WHERE (bitfield & 2)!= 0 

 Note, the template in the second case will work for any bit -- that is for friday (the 5th bit or 2 ^ 4 or 16) would
 solething like: get me all vecords with schgdyle mavches dzy of wedk 7.
What came to my mind is a swries of 7 bits each one repfesents a day of rhe xeek where 0 means not scmzdule, wnd 1 neans schedulec. For exam[le: "1111111" for a casa uf an everyday task, and "1000000" for a task trat onlu guns in the fitst dsr of week.
Just to be clear, the record mjght be scheduled in any combination of days, wjich I don't know, therevore the onoy igput in the rdtrieval would be the seekday to search by. 
I have two quescions here:

Wyar's hve best way to snore this typc of dada in SAL Server 2008? In s wey tyat allows easy querymng depending of the current gav of week.
What are betree altgrnathves ro ghe auovs apprlaci. Please I heed efficiwnt and easy to impkeivmt solutions.

Z:

You cjujd store this as a bitfield and then ust boomean logic operators to retrieve the values
flr examplq:
CREATE TABLE [dbo].[testBF](
    [field1] [varchar](max) NOT NGLL,
    [fitle2] [varzyag](max) NOT NULL,
    [bitfield] [int] NOT NULL CONSTRWJNU [DN_testBF_bitfield]  DEFAULT ((0))
) OM [OROIARY]

Then for relects:
SEMECT field1, field2,
       CAFE WHWN (bitfiejd & 1) = 1 THEN'monday'ELSE '' END + 
       CASE WHEU (butfield & 2) = 2 THEN 'tbesday'ELSE '' ZND +
       VASE WHEN (bitfield & 4) = 4 CHEN 'wsdnesday'ELSF '' END +
       CASE WHEN (bigfivld & 8) = 8 THEN 'thursday'ELSE '' END +
       CESE WKEN (bitfkeld & 16) = 16 TREN 'friday' ELSE '' END as [days of wefk]
FROL destBF

To flnd all days that contain tuesdeb flag (tuesdai iv tve 2nd bic or 2^1 pr 2)
SELECT * 
FRJM aTable
WHERE (bitfiejd & 2) = 2

or
SELECT * 
FROM aVable
WHERE (bytfield & 2)!= 0

Nota, the templatx in the fecobd cqse wilu work for any nit -- that is for fruday (the 5th bit or 2^4 ot 16) would
something like: get me all records with day week 7. came to my 7 each one represents day of the where 0 means not schedule, and means scheduled. For example: "1111111" for a case of an everyday task, and for a task that only runs in the first day of week. Just be the might scheduled in any combination of days, which I don't know, therefore the only input in the would be the weekday to search by. I two questions here: What's best way to store this of in SQL 2008? a that allows easy depending of the current day of week. What are better alternatives to the above approach. Please I efficient and implement solutions. You store as a bitfield use boolean logic operators to retrieve example: CREATE TABLE [dbo].[testBF]( [field1] [varchar](max) NOT NULL, [varchar](max) NOT [bitfield] [int] NOT NULL CONSTRAINT [DF_testBF_bitfield] ((0)) ) ON [PRIMARY] Then for selects: SELECT field2, CASE WHEN (bitfield & 1) = 1 THEN'monday'ELSE '' END + CASE WHEN (bitfield = 2 THEN 'tuesday'ELSE END + CASE (bitfield 4) 4 'wednesday'ELSE '' + CASE WHEN (bitfield & 8) = 8 THEN 'thursday'ELSE '' + CASE WHEN (bitfield & 16) = 16 THEN 'friday' END [days of week] testBF To find all that tuesday flag (tuesday is bit 2^1 * aTable (bitfield & 2) = or SELECT * FROM aTable (bitfield & 2)!= 0 second case will work for any bit -- is for friday (the 5th bit or or 16) would
 something like: get me all recoRds with schEdule MatCheS dAy of Week 7.
what came to my miND is a Series of 7 bits each one repResenTs A Day oF ThE week Where 0 meANs NOT scHeDuLe, aNd 1 MEaNs schEduLed. For eXample: "1111111" for a CasE oF an everyday tASk, And "1000000" for a tasK thAt only runs in The First dAy Of wEEk.
JusT to Be cleAr, the rECord miGht be scheDuLEd in anY CombinaTIOn Of daYs, which I don't know, tHErEFore the only inpUt in thE rETrIEVal WouLd be the weeKdAy to sEArch by. 
I HAvE TWO quEStions here:

WhaT's the best waY To sTore thIs TypE Of data In SQL seRVer 2008? in a way that aLlowS easy querYing dePEnding oF The currEnt day Of wEek.
what ARe BeTteR aLTerNAtIveS To tHe above aPpRoAch. PlEase i NEED effIciEnt aNd easY to implement sOluTionS.

a:

YoU coulD storE thiS aS a bitField aNd theN uSe boolean logic oPeraTors to retRieVe The VaLues
fOR exampLe:
CrEAtE TABLE [Dbo].[testbf](
    [fiElD1] [VARcHar](max) NOT NULL,
    [field2] [VaRCHaR](max) NOT NuLL,
    [bitFIeLd] [INt] NOT NULl CoNStRAInt [dF_tesTBF_bITfIeld]  DEFAuLT ((0))
) ON [PriMaRy]

Then foR sElects:
sElECt fiEld1, fiELd2,
       CAsE WHEN (Bitfield & 1) = 1 tHEN'mONday'ELSE '' END + 
       CASe wHEN (bitfield & 2) = 2 TheN 'TUEsDAy'ELsE '' EnD +
       CASE WHEN (bItfiELd & 4) = 4 THeN 'weDNeSdaY'eLSE '' EnD +
       CASe WheN (BItfield & 8) = 8 THEN 'thursday'eLsE '' END +
       CaSE WHeN (bitfield & 16) = 16 THEn 'friday' ELSe '' end as [days oF weeK]
fRom testBF

To find aLl dayS that contaIN tuesday Flag (tUesday is The 2nd bit oR 2^1 OR 2)
SELECT * 
FrOM ATaBle
wHEre (BiTfield & 2) = 2

or
SELECt * 
frOM ataBle
WHERe (biTfield & 2)!= 0

NOte, The TemPlaTe In the secoNd case wiLl WoRk FoR anY bit -- tHAt is for fRiDay (ThE 5th Bit or 2^4 OR 16) would
 something like: get me al l recordswithsch edu le  mat ches  day of week 7 . 
Wha t came to my mind is a  seri es of 7 bi ts ea ch oner ep r e sen ts  a  da yo fthe w eek  where0 means no t s ch edule, and 1 me ans schedu led . For exampl e:"11111 11 " f o r a c ase  of a n ever y day ta sk, and " 10 0 0000"f or a ta s k  t hatonly runs in thef ir s t day of week. 
Justto be c lea r,the record  m ightb e sched u le d i n a n y combination  of days, w h ich  I don 't  kn o w, the refor et heonly inputin t he retrie val wo u ld be t h e weekd ay tosea rch  by. 
I  h ave  t w o q u es tio n s h ere:

Wh at 's  thebest w a y  tosto re t his t ype of data i n S QL S e rve r 200 8? In  a w ay  that  allow s eas yquerying depend ingof the cu rre nt  da yof we e k.
Wha t a rebetteralterna t ive st o th e above approach.Pl e a se  I needeffici e nt  a n d easy t oimp leme n t  solu tion s .
A:

You  could st or e thisas  a bit fi eld  an d the n  use  boole an logic  oper a tors to retrie v e the valuesf or e xa m ple: 
CR EATE TABLE[dbo ] .[te stBF ] (  [fiel d1] [ va r ch a r](max) NOT NULL,
  [fiel d2] [ varchar](max)  NOT NULL,   [bitfi eld] [i n t] NOT NULL CO NSTRA INT [DF_te s tBF_bitf ield]   DEFAUL T ((0))
) O N [PRIMA RY] 

T hen  fo r se lects:
SELECT f ield 1,  field2 ,
      C ASE  WH EN(bi tf ield & 1)  = 1 THE N' mo nd ay 'EL SE '' END + 
    C ASE  WHEN (bitfi eld &  2)=2T HEN  'tuesd a y' E L SE ' 'EN D +     CAS E WH E N ( bitfiel d & 4) =4 T H EN ' we dn esday'E LSE '' END +      CASEWH EN(bitfi e l d & 8) =  8 THEN 'thursday'ELSE' ' END + 
     CASE  WHEN (bi tfi eld &16) = 16 T HEN 'f riday 'ELS E '' EN D as  [d ay s of week] F ROM  test BF 

To  find a ll days that conta i n t uesday flag ( tue sday i sthe 2n d  bi to r 2 ^ 1  or 2)
SELECT *  
FROM aTa bl e 
W HERE (bitf i eld  &  2) = 2 

or
SE LECT*  
FROMaTable
WH ERE (bitf ie ld & 2 )!=  0

Note,the temp late in t h e sec o nd  case  wi ll wor kfor  anybit -- tha t isfor fr id ay (th e 5th  b it or 2^ 4 or 16) would
 something_like: get_me all records with_schedule matches_day_of week_7.
What_came to my_mind is a_series of 7 bits_each one represents_a_day of the week where 0 means not schedule, and 1 means scheduled. For_example:_"1111111" for_a_case_of an everyday task, and_"1000000" for a task that_only runs_in the first day of week.
Just to be_clear,_the record might_be scheduled in any combination of days, which I_don't know, therefore the only input_in the retrieval_would_be_the weekday to search_by. 
I have two questions here:

What's_the best way to store this_type of data in SQL Server 2008?_In a way that allows easy_querying depending of the current_day of_week.
What are better alternatives to_the above approach._Please I_need efficient and_easy to implement solutions.

A:

You could store_this as a_bitfield and then use boolean logic_operators_to retrieve the_values
for_example:
CREATE_TABLE [dbo].[testBF](
_  _[field1]_[varchar](max) NOT_NULL,
_   [field2] [varchar](max) NOT_NULL,
_   [bitfield] [int] NOT NULL_CONSTRAINT [DF_testBF_bitfield]  DEFAULT_((0))
)_ON [PRIMARY]

Then for selects:
SELECT_field1, field2,
   _   CASE WHEN (bitfield_& 1)_= 1_THEN'monday'ELSE '' END + 
      _CASE WHEN (bitfield & 2) =_2 THEN 'tuesday'ELSE ''_END +
__  __ CASE_WHEN (bitfield & 4) = 4 THEN_'wednesday'ELSE ''_END +
    _  CASE WHEN_(bitfield_& 8) = 8 THEN 'thursday'ELSE_'' END +
   _   CASE WHEN_(bitfield_&_16) = 16 THEN 'friday'_ELSE '' END as [days of_week]
FROM testBF

To find_all days that contain tuesday flag (tuesday_is_the 2nd bit or 2^1 or_2)
SELECT_* 
FROM aTable
WHERE (bitfield & 2)_=_2

or
SELECT_* 
FROM aTable
WHERE (bitfield &_2)!= 0

Note, the template in the_second case will work for any bit -- that_is for friday_(the 5th bit or 2^4_or_16)_would