DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   
Stats
Total Count : 7
Resources Publish New Article  
 
GET/Remove the last character from a string in SQL Server
Ashok Nalam
We will see how to get and remove last character from a string in sql server.
By: Ashok Nalam | 14 Dec 2012 | SQL Server | Views: 19628 | Comments: 0 | Tags:string  tsql 
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: 20749 | Comments: 0 | Tags:cursor  tsql 
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: 9507 | Comments: 0 | Tags:difference  tsql 
Rollback transaction behavior on table variable
Ashok Nalam
By: Ashok Nalam | 24 Jul 2013 | SQL Server | Views: 25248 | Comments: 0 | Tags:table  transactions  tsql 
CONCAT() string function in SQL Server 2012
Ashok Nalam
Article shows how to use CONCAT() function which is introduced with SQL Server 2012 version and also covers different features of it.
By: Ashok Nalam | 10 Feb 2014 | SQL Server | Views: 4891 | Comments: 0 | Tags:SQL Server 2012  string  tsql 
SQL Server: Find database mdf and ldf physical file locations using T-SQL
Ashok Nalam
By: Ashok Nalam | 14 Feb 2014 | SQL Server | Views: 8583 | Comments: 0 | Tags:database  file  tsql 
Set Default Database with SQL Server Management Studio
Ashok Nalam
By: Ashok Nalam | 27 Mar 2014 | SQL Server | Views: 8097 | Comments: 0 | Tags:database  SQL Server  tsql  user