One of the reader Nanda of SQLAuthority.com has posted very detailed script of converting any date time in desired format. I suggest every reader of this blog to save this script in your permanent code bookmark and use it when you need it. Let us learn about User Defined Functions.
SQL SERVER – 2008 – Get Current System Date Time
How to get current system date time in SQL Server?
SQL SERVER – Introduction to SERVERPROPERTY and example
SERVERPROPERTY is very interesting system function. It returns many of the system values. I use it very frequently to get different server values like Server Collation, Server Name etc. Run following script to see all the properties of server. SELECT 'BuildClrVersion' ColumnName, SERVERPROPERTY('BuildClrVersion') ColumnValue UNION ALL SELECT 'Collation', SERVERPROPERTY('Collation') UNION…
Read MoreSQL SERVER – Create a Comma Delimited List Using SELECT Clause From Table Column
I received following question in email : How to create a comma delimited list using SELECT clause from table column?
SQL SERVER – Example of DISTINCT in Aggregate Functions
Just a day ago, I was was asked this question in one of the teaching session to my team members. One of the member asked me if I can use DISTINCT in Aggregate Function and does it make any difference. Of course! It does make difference. DISTINCT can be used…
Read MoreSQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 4
I have been asked many times when there is DATENAME function available why do I go in exercise of writing UDF For the getting the day of the week. Answer is : I just like it! SELECT DATENAME(dw, GETDATE()) Reference : Pinal Dave (https://blog.sqlauthority.com)
Read MoreSQL 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 More