How to create a Unique Index allowing multiple Null Values in SQL Server 2008

by Sumant 1. December 2011 11:43
I have a column in one of the tables in a SQL Server database where the values must be unique. This column can also contain null values. Now, if I add a unique index on this column, it ensures that all values must be unique in the column (and indexes them too), but, that includes null values too. This means that the column can contain only one null value (at most) i.e. duplicate nulls are not allowed! The problem is how to allow multiple null values in a column with unique index? The solution is to ... [More]
Share   

Tags: ,

MS SQL Server

SQL Server Data Types and Their .NET Framework Equivalents

by Sumant 29. January 2008 12:08
http://msdn2.microsoft.com/en-us/library/ms131092.aspx
Share   

Tags:

MS SQL Server

SQL Server Error : 'function_name' is not a recognized name

by Sumant 14. June 2007 10:27
A silly issue, but may bug you if you are not a regular sql server udf user. Whenever a scalar-valued user defined function is invoked just using the name of the function, single part, you will get an error like - Msg 195, Level 15, State 10, Line 1 'function_name' is not a recognized function name. To resolve this use at least two part function name (by prefixing it with owner). example : (1) Select MyScalarFunction() -- wrong usage (2) Select dbo.MyScalarFunction() -- correct usage Important thing to note is that table-valued function, unlike scalar-valued, can be called using single part name. Tip: to avoid using multi part naming in sql server 2005, you can use synonyms. [more reading on user defined functions]
Share   

Tags:

MS SQL Server

MS SQL Server : The Game of Dynamic SQL

by Sumant 13. March 2007 14:55
No matter how much we try to avoid dynamic sqls in our queries, there are times when we have no other choice than to use it. I have experienced that in general all programmers are not very well aware of the truths and myths related to dynamic sql queries and at times they end up implementing a solution that might not be the best one for their scenario. I am not going to write about the truths and myths of dynamic sql here, but will point you to this article "The Curse and Blessings of Dynamic SQL" by Erland Sommarskog, which I came across long back. The article is very informative and is updated with latest changes in SQL Server. There are other articles from Erland on the same web and they are also equally informative and exhaustive. Also, there are other very useful links on the site that are related to SQL Server. A site - must to be in the 'favorites list' of any MS SQL programmer.
Share   

Tags:

MS SQL Server

© 2008 Sumant Dubey

About this blog

Absolutely technical! The posts are about concepts, tricks, articles and links on technical subjects / problems which are not very obvious to understand / resolve. Purpose is to have this as the first-aid in the time of need.

RecentComments

Disclaimer

The opinions expressed on this website are my own personal opinions and do not represent my employer's view in anyway.