Monday, December 11, 2017

How to find duplicate records from sql server Table and Delete

How to find the duplicate record ?

Finding duplicate record from table using CTE.

WITH CTE
AS
(SELECT NAME,EMP_ID,ROW_NUMBER()
OVER(PARTITION BY NAME ORDER BY NAME)
AS NAMEDUP FROM EMPLOYEE)
SELECT * FROM CTE WHERE NAMEDUP > 1 ORDER BY NAME

Using Having Count

SELECT NAME,COUNT(NAME)FROM EMPLOYEE
GROUP BY NAME HAVING COUNT(*)>1

Using group by

SELECT NAME,COUNT(NAME) AS CNT
FROM EMPLOYEE
GROUP BY NAME

Deleting duplicate records from the table.

WITH CTE
AS
(SELECT NAME,EMP_ID,ROW_NUMBER()
OVER(PARTITION BY NAME ORDER BY NAME)
AS NAMEDUP FROM EMPLOYEE)
DELETE FROM CTE WHERE NAMEDUP > 1



Wednesday, December 6, 2017

How to set Sql Server Mode In IIS in ASP.NET ?

1.We need not to create a  new database We have a tool called aspnet_regsql.exe tool (Aspnet registersql).
This tool is present in c:\windows\Microsoft.net\framework64\version.
2.In the Run command window prompt we have to run below mentioned commands
A.In that mentionpath where the tool exists,Toolname -s Sqlservername -E(Means windowauthentication) -ssadd(Add support for SQL serve sessionmode -sstype p(MeansSession variables will store in ASP state sql server database)
3.Need to set mode to SQLserver
<sessionstate mode="SqlServer" sqlconnectionstring="datasource=.; userid="username" pwd="p***"/>




Blog Archive

Don't Copy

Protected by Copyscape Online Plagiarism Checker

Pages