To determine weekday or weekend using T-SQL

SQL Server UDF
create function fn_IsWeekDay
(
    @date datetime
)
returns bit
as
begin

    declare @dtfirst int
    declare @dtweek int
    declare @iswkday bit

    set @dtfirst = @@datefirst – 1
    set @dtweek = datepart(weekday, @date) – 1

    if (@dtfirst + @dtweek) % 7 not in (5, 6)
        set @iswkday = 1 –business day
    else
        set @iswkday = 0 –weekend

    return @iswkday
end

Usage:
if dbo.fn_IsWeekDay(@date) = 1
    select ‘WeekDay’
else
select ‘WeekEnd’

Advertisements

Team Foundation Server is not compatible with SQL Server Collation

[ Configuration Database ] TF255374: The following SQL Server instance is not compatible with Team Foundation Server: VBXW2008\SQLSVR08. The default collation is set to Latin1_General_CI_AI. Team Foundation Server requires that the default collation be case insensitive and accent sensitive. You must choose a SQL Server instance whose default collation settings match these requirements

Run the following statement to fix:
Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=SQLSVR08 /SQLSYSADMINACCOUNTS=vbxw2008\administrator /SAPWD=password /SQLCOLLATION=Latin1_General_CI_AS

Identify SQL Server Version