Merry Christmas – From SQL Server

Below is the script which you can run directly in your SSMS and SQL Server (With the power of  Spatial results) sends you Christmas wishes directly on your screen 🙂


USE tempdb
GO


-- Prepare the scene

CREATE TABLE #ChristmasScene

(

item VARCHAR(32)

,shape GEOMETRY
) ;

--Put up the tree and star

INSERT INTO #ChristmasScene

VALUES ( 'Tree',

'POLYGON((4 0, 0 0, 3 2, 1 2, 3 4, 1 4, 3 6, 2 6, 4 8, 6 6, 5 6, 7 4, 5 4, 7 2, 5 2, 8 0, 4 0))' ),

( 'Base', 'POLYGON((2.5 0, 3 -1, 5 -1, 5.5 0, 2.5 0))' ),

( 'Star',

'POLYGON((4 7.5, 3.5 7.25, 3.6 7.9, 3.1 8.2, 3.8 8.2, 4 8.9, 4.2 8.2, 4.9 8.2, 4.4 7.9, 4.5 7.25, 4 7.5))' )

--Decorate the tree

DECLARE @i INT = 0

,@x INT

,@y INT ;

WHILE ( @i < 20 )

BEGIN

INSERT INTO #ChristmasScene

VALUES ( 'Bauble' + CAST(@i AS VARCHAR(8)),

GEOMETRY::Point(RAND() * 5 + 1.5, RAND() * 6, 0).STBuffer(0.3) )

SET @i = @i + 1 ;

END

--Christmas Greeting

INSERT INTO #ChristmasScene

VALUES ( 'M',

'POLYGON((0 10, 0 11, 0.25 11, 0.5 10.5, 0.75 11, 1 11, 1 10, 0.75 10, 0.75 10.7, 0.5 10.2, 0.25 10.7, 0.25 10, 0 10))' ),

( 'E',

'POLYGON((1 10, 1 11, 2 11, 2 10.8, 1.25 10.8, 1.25 10.6, 1.75 10.6, 1.75 10.4, 1.25 10.4, 1.25 10.2, 2 10.2, 2 10, 1 10))' ),

( 'R',

'POLYGON((2 10, 2 11, 3 11, 3 10.5, 2.4 10.5, 3 10, 2.7 10, 2.2 10.4, 2.2 10, 2 10),(2.2 10.8, 2.8 10.8, 2.8 10.7, 2.2 10.7, 2.2 10.8))' ),

( 'R',

'POLYGON((3 10, 3 11, 4 11, 4 10.5, 3.4 10.5, 4 10, 3.7 10, 3.2 10.4, 3.2 10, 3 10),(3.2 10.8, 3.8 10.8, 3.8 10.7, 3.2 10.7, 3.2 10.8))' ),

( 'Y',

'POLYGON((4 11, 4.2 11, 4.5 10.6, 4.8 11, 5 11, 4.6 10.5, 4.6 10, 4.4 10, 4.4 10.5, 4 11))' ),

( 'C',

'POLYGON((0 9, 0 10, 1 10, 1 9.8, 0.2 9.8, 0.2 9.2, 1 9.2, 1 9, 0 9))' ),

( 'H',

'POLYGON((1 9, 1 10, 1.2 10, 1.2 9.6, 1.8 9.6, 1.8 10, 2 10, 2 9, 1.8 9, 1.8 9.4, 1.2 9.4, 1.2 9, 1 9))' ),

( 'R',

'POLYGON((2 9, 2 10, 3 10, 3 9.5, 2.4 9.5, 3 9, 2.7 9, 2.2 9.4, 2.2 9, 2 9),(2.2 9.8, 2.8 9.8, 2.8 9.7, 2.2 9.7, 2.2 9.8))' ),

( 'I',

'POLYGON((3.2 9, 3.2 9.2, 3.4 9.2, 3.4 9.8, 3.2 9.8, 3.2 10, 3.8 10, 3.8 9.8, 3.6 9.8, 3.6 9.2, 3.8 9.2, 3.8 9, 3.2 9))' ),

( 'S',

'POLYGON((4 9, 4 9.2, 4.8 9.2, 4.8 9.4, 4 9.4, 4 10, 5 10, 5 9.8, 4.2 9.8, 4.2 9.6, 5 9.6, 5 9, 4 9))' ),

( 'T',

'POLYGON((5 9.8, 5 10, 6 10, 6 9.8, 5.6 9.8, 5.6 9, 5.4 9, 5.4 9.8, 5 9.8))' ),

( 'M',

'POLYGON((6 9, 6 10, 6.25 10, 6.5 9.5, 6.75 10, 7 10, 7 9, 6.75 9, 6.75 9.7, 6.5 9.2, 6.25 9.7, 6.25 9, 6 9))' ),

( 'A',

'POLYGON((7 9, 7 10, 8 10, 8 9, 7.75 9, 7.75 9.3, 7.25 9.3, 7.25 9, 7 9),(7.25 9.5, 7.25 9.8, 7.75 9.8, 7.75 9.5, 7.25 9.5))' ),

( 'S',

'POLYGON((8 9, 8 9.2, 8.8 9.2, 8.8 9.4, 8 9.4, 8 10, 9 10, 9 9.8, 8.2 9.8, 8.2 9.6, 9 9.6, 9 9, 8 9))' ) ;

--Admire the scene

SELECT *

FROM #ChristmasScene -- Tidy up the pine needles and put away the decorations

DROP TABLE #ChristmasScene

After letting it run (Shouldn’t take more than a second), navigate to ‘spatial results’ tab in your results pane and voila…..

The total credit goes to the original author of this script. Unfortunately, I don’t have his/her name, I saved this script years ago in my tool set.

Wishing you all Merry Christmas and a very happy new year 🙂

Advertisements

SQL Server 2016 announced :)

Not sure if you guys have got a chance to grab updates from Microsoft Ignite event(Previously called TechEd), So here is a news for you. Microsoft CEO Satya Nadella announced SQL Server 2016 day before yesterday. It’s not yet available to download for public, but they are saying it(public preview) will be available soon 🙂

Looks like they have lot of enhancements in encryption(Always Encrypted…sounds very similar to AlwaysON) area and cloud integration/BI/Polybase areas.

For data sheet and other details please check
http://www.microsoft.com/en-us/server-cloud/products/sql-server-2016/default.aspx
and
http://blogs.technet.com/b/dataplatforminsider/archive/2015/05/04/sql-server-2016-public-preview-coming-this-summer.aspx

Am all set for getting my hands dirty playing with Public preview release…

 

Idera’s SQL Extended Events Profiler – concise and Elegant tool for SQL DBAs!

In this blog post, I would like to introduce all of you to a very cool and concise Free tool from Idera.

Note:  I Do not work for Idera. Idera has nothing to do with this blog post. Am expressing just my opinion with my experiences with this free tool.

Okay, so….what is this tool al about?

If you are a SQL Server DBA, you might have already been in a situation where you had to run SQL Server trace on your SQL Server(s) per a developer request or for investigation purposes or some thing else.  Profiler, which comes with SQL Server installtion is a very heavy tool, especially if you are  not filtering out your events when running your trace. To avoid any overhead this graphical tool(profiler) causes, we could use “Server Side tracing” which basically runs the trace server side and stores the results either in a file or a table without the need for using profiler(Which constantly displays the results, which is very resource intensive). Impressive…But not as impressive as “Extended Events”. MSFT introduced “Extended Events” in SQL Server 2008 which is the low level/High performance eventing solution. Slowly and steadily…I am seeing people moving away from traces and Profiler which is nice.  If you are a SQL Server Profiler person, I’ve got a sad news for you, Profiler is depricated in SQL Server 2014(Instead, microsoft is asking you to use Extended events session(s) which is embedded in your SSMS under management Node). You might not like this initially, especially the way how you’ve to interact with XEvents from SSMS. This is where this free tool from Idera comes handy. This is very similar to how you would interact with Profiler(Selecting templates, events, filtering columns etc), but instead of starting a trace, it pulls info from Extended events which are very light weight and has significantly less over head on your SQL Server.

See below Screenshots on what am talking about…If you are already familiar with Profiler, this doesn’t need any further explanation on how to get started with this free tool.

1

Once connected, choose your template

2

Filter out columns as needed…

3

As you can see this could be very helpful tool to track down few things on your SQL Server without hindering it’s performance. Once you’ve got what you are lookin for, you can export the results as well.  This is a free tool, you can download it from idera and play with it and see if it meets your requirements.

PS Discussing the true power of Extended events which microsoft introduced for us is way beyond scope of this blog post.

Cheers!

And I gave it a new name & identity…

Hello folks…I am very pleased to announce a brand new name and identity which I’ve given to my blog. It will be http://www.mssqltrek.com from now on.

A brand new Name in brand new year 🙂 Welcome to 2014…

Well, you will be redirected automatically to the new URL even if you visit sqlbuzz.wordpress.com 😀
For feedback and suggestions, please shoot an email to sree@mssqltrek.com.

Thank you – Sree!

How to boot directly into your regular desktop Screen in Windows 8.1?

With the new windows 8.1, it is very simple to bypass the new start(Live Tiles) Screen if you want to and directly boot into regular Desktop mode. Let me show you how…

Nope! That’s not a setting in control Panel and not even in your task manager….! Once you login to your windows machine, switch to your legacy Desktop screen  and right click on task bar and go to Properties and navigate to “Navigation” tab.  Now at the bottom section(Start Screen) select “When I sign in or close all apps on a screen, go to desktop instead of start” as shown below and click Apply->ok. That’s it…You are good to go 🙂

1

 

Very Simple huh…!