Posts

Delete duplicate records using this script in MS Sql Server

Hi Friends , You can delete duplicate records using this script in MS Sql Server. I write a example below. Declare @tblEmployee As table  ( Eid int, Ename varchar(10) )   insert into @tblEmployee values(1,'A') insert into @tblEmployee values(2,'B') insert into @tblEmployee values(3,'A') insert into @tblEmployee values(4,'D') insert into @tblEmployee values(5,'B') Select * from @tblEmployee  Delete From @tblEmployee Where Eid in ( Select Eid from  (Select * , ROW_NUMBER() Over ( partition by Ename Order by Ename ) As ICount  From @tblEmployee )As Qry Where Qry.ICount > 1 ) Select * from @tblEmployee 

Windows Service Install and Un Install in MS VisualStudio 2010

Hi Friends, You can learn How to Install and Un Install Windows Service using Microsoft Technology. >> 1 .First get the path where InstallUtil.exe exist its Mostly the path is same but differ version  it can be differ C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe >> 2 .Get the Path where you want to put that Service .exe file (Assume it is on "E:\MyApp\MyTestApp.exe") >> 3 .Command for Install service Run Visual Studio Command Prompt as Run admin if Windows 8 else no need to it and Type this C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe E:\MyApp\MyTestApp.exe -i >> 4 .Command for Un Install service Run Visual Studio Command Prompt as Run admin if Windows 8 else no need to it and Type this C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe E:\MyApp\MyTestApp.exe -u >> 5 .In case if you already installed Service and you can see there "services.msc" Service list and you have

Find Store Procedures and Functions in MS SQL Server.

Hi Friends , This article will help you to find Store Procedures and Functions in Microsoft SQL Server. Execute this Script which i mentioned below. ROUTINE_TYPE =  'PROCEDURE' OR    'Function' Select  ROUTINE_TYPE , SPECIFIC_NAME , ROU TINE_DEFINITION FROM     INFORMATION_SCHEMA.ROUTINES WHERE    OBJECTPROPERTY ( OBJECT_ID ( SPECI FIC_NAME ), 'IsMSShipped' )   = 0         AND  ROUTINE_DEFINITION   like   '%PrcName%'         AND  ROUTINE_TYPE = 'PROCEDURE'

Draw Line and Text on Bitmap Image in C#

Hello Friends ,  This is a sample Class example of C#,using this code you can Draw the text and line using Graphics pen on Bitmap images. Sample example code (C# Language - VS.Net) ---------------------------------------------------------------------------------------------------------- using System; using System.Drawing; using System.IO; using System.Diagnostics; using System.Data; using System.Drawing.Imaging; using System.Threading; using System.Collections; using System.Globalization; using System.Windows.Forms; using System.Configuration; using System.Net; using System.Net.Mail; using System.Net.NetworkInformation; namespace MyTest { public class GenerateImage { private Thread [] threads; private System.Collections. Hashtable hashConnectionInfo = new System.Collections. Hashtable (); public string appPath = "E:\\MyPenImage\\" ; public GenerateImage()

Recursive CTE in SQL SERVER

Step1. Create Table CREATE TABLE [dbo].[RegMast]( [RegID] [int] NOT NULL, [RegNo] [varchar](12) NULL, [RegName] [varchar](50) NULL, [UplineRegID] [int] NULL, [UplineLeg] [varchar](1) NULL, [SponsorRegID] [int] NULL, [IsActive] [bit] NULL, [FirstName] [varchar](50) NULL, [MIddleName] [varchar](50) NULL, [LastName] [varchar](50) NULL, [Password] [nchar](10) NULL, [DateofJoin] [datetime] NULL, [DateofBirth] [datetime] NULL, [Occupation] [varchar](50) NULL, [Qualification] [varchar](50) NULL, [EmailID] [varchar](15) NULL, [ContactNo] [varchar](10) NULL, [Photo] [varchar](50) NULL, [IsDelete] [bit] NULL, [IsCreatedOn] [datetime] NULL, [IsUpdatedOn] [datetime] NULL, [IsDeletedOn] [datetime] NULL,  CONSTRAINT [PK_RegMast] PRIMARY KEY CLUSTERED  ( [RegID] ASC )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] ) ON [PRIMARY] Step 2. Declare @RegI

Delete duplicate records in SQL Server

Declare @tbl As table  ( iid int, iname varchar(10) )   insert into @tbl values(1,'A') insert into @tbl values(2,'B') insert into @tbl values(3,'C') insert into @tbl values(4,'A') insert into @tbl values(5,'C') Select * from @tbl  Delete From @tbl Where iid in ( Select iid from  (Select * , ROW_NUMBER() Over ( partition by iname Order by iname ) As ICount  From @tbl) As Qry Where Qry.ICount > 1 ) Select * from @tbl

Repair Suspect Database using Query In SQL Server

This is the query to repair suspect database in SQL Server.   If your Database is marked as suspected, here are the steps to fix it.       In this you have replace “dbName” with suspected db name and run this query in master database. Step 1 --command to recover suspected database ALTER DATABASE DbName SET EMERGENCY DBCC checkdb('DbName') ALTER DATABASE DbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE DBCC CheckDB ('DbName', REPAIR_ALLOW_DATA_LOSS) ALTER DATABASE DbName SET MULTI_USER          This step 1 cannot set Index created for that database so now we have to rebuild the index. This query should be run in that suspected database. Step 2 -- command to rebuild all indexes EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"