Determining if a Date is a Weekday in T-SQL

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 = [...]

[TSQL]How to get list of Table in MS-SQL

USE [TABLE_NAME] SELECT * FROM sys.Tables ORDER BY NAME

List all the Stored Procedures of a Database and their Definitions using T-SQL in SQL Server 2005/2008

SELECT obj.Name as SPName,

modu.definition as SPDefinition,

obj.create_date as SPCreationDate

FROM sys.sql_modules modu

INNER JOIN sys.objects obj

ON modu.object_id = obj.object_id

WHERE obj.type = ‘P’

SQL Change column name in table

Using the Query Analyzer may not be the right way always, you can use the SQL syntax as given below, if you are unable to have access to use the query analyzer

For Oracle 9i, the syntax is : ALTER TABLE table_name RENAME COLUMN old_name to new_name;

For Microsoft SQL the syntax is : [...]