SQL Server - Transact-SQL eBook by TechNet Wiki Community

Excel - Separate the contents of one cell into separate columns

This articles is about separating the contents in one cell into separate columns in excel .

Suppose we are copying text from notepad as shown below :

T-SQL: Script to Find the Names of Stored Procedures that Use Dynamic SQL ( Method 2 )

First method was using dynamic management function - sys.dm_sql_referenced_entities .

Fun with system functions continues ...

Here is the second method : Using dynamic management function - sys.dm_exec_describe_first_result_set

SQL Server - Calender details

Below T-SQL script using common table expression will provide the calender details:

DECLARE @StartDate DATE = '2014-01-01', @EndDate DATE = '2014-12-31' 
;With CTE
SELECT @StartDate dt 
WHERE dt < @EndDate
FORMAT ( dt, 'D', 'en-US' ) Calender
,DATENAME(dayofyear, dt) DayNumber_Year
,DATEPART(day, dt) DayNumber_Month
,DATEPART(weekday, dt) DayNumber_Week
,DATENAME(weekday, dt) DayName
,DATEPART(WEEK,dt) WeekNumber
,IIF ( DATEPART(weekday, dt) IN (1,7) , 'Weekend', 'Weekday' ) Day
,DATENAME(month, dt) MonthName
,DATEPART(month, dt) MonthNumber
,DATENAME(year, dt) Year
,EOMONTH (dt) MonthLastDate
FROM cte

SQL Server - Dynamic SQL - SQL Injection - EXEC [ QUOTENAME() , REPLACE() , EXECUTE AS ] - Sp_executesql - [ RECOMPILE ]

Recently I had mess up with dynamic SQL , So whats next !!! , I started to explore on this topic and post it here , when I googled to gather some information , but what I found was , this topic has been already drilled to the core , carved and with the sculpture mounted on the walls of SQL Server by some of the great SQL Server guru's , much before an year I started to work with SQL Server .

For my regular readers , I will definitely share the good links with the abstract from the same .

To execute a string , we can make use of sp_executesql or EXEC - “Dynamic String Execution”  (DSE)

As mentioned in the BOL :