Friday, November 29, 2013

TSQL Rambling


Wanted to share my thoughts on three interesting things stumbled across in TSQL


1. SQL Unary Operator


Lets create a simple table as follows


declare @TestPlus table
(
Type varchar(2),
TypeName varchar(10),
code int
)


insert into @TestPlus values ('P', 'Procedure', 1)
insert into @TestPlus values ('T', 'Table', 2)
insert into @TestPlus values ('V', 'View', 3)
insert into @TestPlus values ('F', 'Function', 4)


What is the output for the following select query?


select Type from @TestPlus where Code in ( +1, +++3, +4)


select +++Type from @TestPlus where Type in (+'P', +++'T')


When I saw this select query for a second I thought its trick question on how to use ++ operator, however it turns out that the result has nothing to do with the “+++” operator. Quickly browsed through MSDN and found that it has no effect on the evaluated expression


“Although a unary plus can appear before any numeric expression, it performs no operation on the value returned from the expression.”





I was surprised to see a query like this


;with cte as
(
select dddid, payorid
from (values  ('100100', 1), ('100101', 2), ('100102',3 ) ) f(ClientID, SeqNo)
)


select * from cte where SeqNo = 3


turns out that this type of query is called row constructor a new feature introduced in SQL 2008.



3.  SQL Strict Names


Check out the following queries, spot the odd man out


select top 10  * from [dbo].[TestUpSurdTable]


select top 10  * from [dbo].[TestUpSurdTable]_Final


I was expecting two different result sets however the same result set was repeating twice, turns out that the “[ ]” ignored what ever is after the underscore

Sunday, November 17, 2013

Best Data Visualization Libraries

Best Data Visualization Libraries

I just observed a  trend for inforgraphic style of reporting in business. Infographic reports very tangible, click, drag, drop, add elements which makes the report more like a stand alone app.

I complied a short list visualization libraries based on javascript which I personally used. I will be updating this list as I find something interesting.

1. Google Charts

2. Data Driven Documents

3. Protovis
http://mbostock.github.io/protovis/

Saturday, November 16, 2013

Visual Studio 2012 Designer Issues

I recently uninstalled visual studio 2012 from my PC which already had VS2010 installed. The uninstall messed up the UI designer dll’s and I got the following errors in SSIS & SSMS

Couldn’t open SSIS packages


The database diagram designer had trouble opening..



The cause the dll’s at the following location are corrupted
C:\Program Files (x86)\Common Files\microsoft shared\MSDesigners8

The fix:
1.       Use the installation CD  of vs2010 and repair or
2.       Just copy the MSDesigners8 files from a PC which doesn’t have this issue.
The second choice is easier, I copied the files from my colleagues PC and replaced the contents in the MSDesigners8  folder. 


You if you have the same issue, you can download  the dll’s  here
https://drive.google.com/file/d/0Bz1hNSwS5Wi4WU95OG5ERTQ4cG8/edit?usp=sharing