DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   
Stats
Total Count : 79
Resources Publish New Article  
 
Does UNIQUE KEY supports more than one NULL Value?
Ashok Nalam

No. In SQL server we can insert only one NULL value to column which has UNIQUE KEY constraint.

Example:

CREATE TABLE SamepleUnique
(
Id INT PRIMARY KEY,
Name varchar(20) UNIQUE
)
INSERT INTO SamepleUnique VALUES(1,'Ram')
INSERT INTO SamepleUnique VALUES(2,'Krish')
INSERT INTO SamepleUnique VALUES(3,Null)
INSERT INTO SamepleUnique VALUES(4,Null) --Error as Violation of UNIQUE KEY constraint 'UQ__SamepleU__737584F603317E3D'. Cannot insert duplicate key in object 'dbo.SamepleUnique'.
--The statement has been terminated.


By: Ashok Nalam | 12 Dec 2012 | SQL Server | Views: 4731 | Comments: 1 | Tags:Constraints  unique key 
calling Javascript validation function before button click event in ASP.NET - onclientclick before onclick
Ashok Nalam
In this snippet we will see how to call a java script client side validation function before server side method execution.
By: Ashok Nalam | 13 Dec 2012 | ASP.NET | Views: 76050 | Comments: 0 | Tags:button  C#  javascript  onclick  onclientclick 
convert IP address to binary format using IPAddress Class in C#.NET
Ashok Nalam
In this snippet we will see how to convert an IP address to binary format using System.Net.IPAddress class.
By: Ashok Nalam | 15 Dec 2012 | C# | Views: 18450 | Comments: 0 | Tags:binary  converter  ip-address 
Constant variables in .NET
Ashok Nalam
In this article we will discuss about constant variables in .NET and with sample program.
By: Ashok Nalam | 15 Dec 2012 | C# | Views: 8060 | Comments: 0 | Tags:const  variable 
Implementing Singleton class in .NET
Ashok Nalam
In this article we will discuss about the implementation of singleton class in .NET with sample program.
By: Ashok Nalam | 16 Dec 2012 | C# | Views: 4518 | Comments: 0 | Tags:class  design pattern  singleton 
converting generic list/object to JSON and JSON to list/Object using JavaScriptSerializer in .NET
Ashok Nalam
In this article we will see how to convert an .NET object or generic list to JSON and JSON to .NET object or list using JavaScriptSerializer class.
By: Ashok Nalam | 17 Dec 2012 | C# | Views: 50307 | Comments: 0 | Tags:conversion  generics  JSON  list 
jsdebug issue for webservice call from ajax - NetworkError: 500 Internal Server Error
Ashok Nalam
We will see how to resolve the jsdebug issue while calling a web service from ajax.
By: Ashok Nalam | 19 Dec 2012 | ASP.NET | Views: 7121 | Comments: 0 | Tags:error  javascript  webservice 
Looping through rows without cursors in Sql server using while loop
Ashok Nalam
In this snippet we will see how to iterating through the table rows data with out using cursor in SQL server.
By: Ashok Nalam | 22 Dec 2012 | SQL Server | Views: 20248 | Comments: 0 | Tags:cursor  tsql 
Accessing parent class data members from derived class using base keyword in .NET
Ashok Nalam
we will see how to access parent class data member from derived class using base keyword
By: Ashok Nalam | 26 Dec 2012 | C# | Views: 48682 | Comments: 0 | Tags:inheritance  oops 
Difference between count(*) and count(column_name)
Ashok Nalam
We might assume that count(*) and count(column_name) will return same result count. But NO, in case of column holds any null values.

Count (*) – returns all values (including nulls and duplicates)
Count (Column_Name) – returns all Non-NULL values(including duplicates)

In the below script we will see how it works. So that it will be easy for us to understand.
create table #tempTable(Name char(1))
insert into #tempTable values("A")
insert into #tempTable values("B")
insert into #tempTable values(Null)
insert into #tempTable values("C")
insert into #tempTable values(Null)
insert into #tempTable values("C")
select COUNT(*) from #tempTable
select COUNT(Name) from #tempTable
drop table #tempTable
Output: 6 and 4
The table #temptable has total 6 rows. Count(*) returns all the rows including null/duplicates but where as count(name) returns only 4 rows which includes duplicates("C") but not null values.

If you want to remove the duplicates from count(Name) then use distinct keyword in it.
select COUNT(distinct Name) from #tempTable –-returns 3
By: Ashok Nalam | 28 Dec 2012 | SQL Server | Views: 9176 | Comments: 0 | Tags:difference  tsql 
12345678