SQL SERVER – Few Useful DateTime Functions to Find Specific Dates

Recently I have recieved email from Vivek Jamwal, which contains many useful SQL Server Date functions. ----Today SELECT GETDATE() 'Today' ----Yesterday SELECT DATEADD(d,-1,GETDATE()) 'Yesterday' ----First Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) 'First Day of Current Week' ----Last Day of Current Week SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6) 'Last Day of Current Week' ----First Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0) 'First Day of Last Week' ----Last Day of Last Week SELECT DATEADD(wk,DATEDIFF(wk,7,GETDATE()),6) 'Last Day of Last Week' ----First Day of Current Month SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) 'First Day of Current Month' ----Last Day of Current Month SELECT DATEADD(ms,- 3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0))) 'Last Day of Current Month' ----First Day of Last Month…
Read More

SQLAuthority News – SQL Server Express 2008 Downloads

Microsoft SQL Server 2008 Express with Tools Microsoft SQL Server 2008 Express with Tools (SQL Server 2008 Express) is a free, easy-to-use version of SQL Server Express that includes graphical management tools. SQL Server 2008 Express provides powerful and reliable data management tools and rich features, data protection, and fast…
Read More

SQL SERVER – How to Rename a Column Name or Table Name

I often get requests from blog reader for T-SQL script to rename database table column name or rename table itself. Here is a video demonstrating the discussion [youtube=http://www.youtube.com/watch?v=5xviNDISwis] The script for renaming any column : sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN' The script for renaming any object (table, sp etc) :…
Read More

SQLAuthority News – Ahmedabad SQL Server User Group Meeting – August 2008

I will be attending Ahmedabad SQL Server Usergroup Meeting on August 30, 2008. I will be taking session about “SQL Server CTE and Recursive CTE“. The most important part of August Meeting is there will be presentation on “Transaction Isolation Levels and Locks in SQL Server” from user group President…
Read More