Very frequently Jr. Developers request script for creating default constraint over table column. I have written following small script for creating default constraint. I think this will be useful to many other developers who want this script to keep handy.
SQL SERVER – UNPIVOT Table Example
My previous article SQL SERVER – PIVOT Table Example encouraged few of my readers to ask me question about UNPIVOT table. UNPIVOT table is reverse of PIVOT Table. USE AdventureWorks GO CREATE TABLE #Pvt ([CA] INT NOT NULL, [AZ] INT NOT NULL, [TX] INT NOT NULL); INSERT INTO #Pvt ([CA],…
Read MoreSQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 3
Datetime functions and stored procedures always interests me. Nanda Kumar has suggested modification to previous written article about SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 2. He has improved on UDF. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS VARCHAR(10) AS BEGIN DECLARE…
Read MoreSQL SERVER – T-SQL Script to Devide One Column into Two Column
Just a day ago, we faced situation where one column in database contained two values which were separated by comma. We wanted to separate this two values in their own columns. It was interesting that value of the column was variable and something dynamic needed to be written. Following is…
Read MoreSQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 2
I have written article about SQL SERVER – UDF – Get the Day of the Week Function. I have received good modified script from reader Mihir Popat has suggested another code where Sunday does not have to be necessary the first day of the week. CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME) RETURNS…
Read MoreSQL SERVER – PIVOT Table Example
This is quite a popular question and I have never wrote about this on my blog. A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table.
SQL SERVER – Find Table in Every Database of SQL Server – Part 3
Previously I wrote two articles about SQL SERVER – Find Table in Every Database of SQL Server SQL SERVER – Find Table in Every Database of SQL Server – Part 2 I recently received email from SQL Expert and Blog Reader Greg Steinkuhler. People like Greg Steinkuhler makes this whole…
Read More