Using a Correlated Subquery to Delete Duplicate Records
CREATE TABLE Dups (NameId int, FirstName varchar(10), LastName varchar(10))
GO INSERT INTO Dups VALUES (106, 'Robert', 'Aide')
INSERT INTO Dups VALUES (107, 'David', 'Koidl') INSERT INTO Dups VALUES
(108, 'Hongbo', 'Li') INSERT INTO Dups VALUES (123, 'Robert', 'Aide') INSERT
INTO Dups VALUES (124, 'David', 'Koidl') INSERT INTO Dups VALUES (125,
'Hongbo', 'Li') INSERT INTO Dups VALUES (138, 'Robert', 'Aide') INSERT INTO
Dups VALUES (139, 'David', 'Koidl') INSERT INTO Dups VALUES (140, 'Hongbo',
'Li') INSERT INTO Dups VALUES (153, 'Robert', 'Aide') INSERT INTO Dups
VALUES (154, 'David', 'Koidl') INSERT INTO Dups VALUES (155, 'Hongbo', 'Li')
GO
DELETE FROM dups WHERE EXISTS ( SELECT NameId FROM dups DupsInner WHERE
DupsInner.FirstName = Dups.FirstName AND DupsInner.LastName = Dups.LastName
AND DupsInner.NameId < Dups.NameId )
GO
Ritesh Kesharwani
SQL Star Intlernational Ltd.
Riteshk@sqlstarintl.com
Ritesh_kk2000@yahoo.com
www.Riteshk.blogspot.com
Cell - 9849976150
Wednesday, July 28, 2004
Tuesday, July 27, 2004
Retrive records without column name
Hi,
Create a Stored Procedure or Function using following script, and pass
tablename and NoOfColumns as Input Parameters. You problem is solved
Declare @TableName nvarchar(1000)
Declare @NoOfColumns Int
Set @NoOfColumns = 3
Set @TableName = 'Stores'
Declare @ID INT
Declare @SqlString nvarchar(3000), @SqlString1 nvarchar(3000)
Set @SQLString = 'Select '
Select @ID = id From SYSOBJECTS WHERE xtype = 'U' and Name = @TableName
Declare @SQlParameters nvarchar(1000)
Set @SqlParameters = N'@SQLStringnvarchar(3000)
OUTPUT, @ID Int'
Set @SqlString1 = 'Select Top ' + Cast(@NoOfColumns as varchar(5)) + '
@SQLString = @SQLString + '' '' + name + '','' From SYSCOLUMNS WHERE id =
@ID order by colid'
PRINT @SQLString1
Exec sp_executesql @SqlString1, @SqlParameters, @SqlString OUTPUT, @ID
SeT @SQLString = Left(@SqlString, Len(@SqlString) - 1) + ' From ' +
@tablename
Exec sp_executesql @SqlString
Create a Stored Procedure or Function using following script, and pass
tablename and NoOfColumns as Input Parameters. You problem is solved
Declare @TableName nvarchar(1000)
Declare @NoOfColumns Int
Set @NoOfColumns = 3
Set @TableName = 'Stores'
Declare @ID INT
Declare @SqlString nvarchar(3000), @SqlString1 nvarchar(3000)
Set @SQLString = 'Select '
Select @ID = id From SYSOBJECTS WHERE xtype = 'U' and Name = @TableName
Declare @SQlParameters nvarchar(1000)
Set @SqlParameters = N'@SQLString
OUTPUT, @ID Int'
Set @SqlString1 = 'Select Top ' + Cast(@NoOfColumns as varchar(5)) + '
@SQLString = @SQLString + '' '' + name + '','' From SYSCOLUMNS WHERE id =
@ID order by colid'
PRINT @SQLString1
Exec sp_executesql @SqlString1, @SqlParameters, @SqlString OUTPUT, @ID
SeT @SQLString = Left(@SqlString, Len(@SqlString) - 1) + ' From ' +
@tablename
Exec sp_executesql @SqlString
Monday, July 26, 2004
How to embed .Net User control in an Html Page
Hi,
Yes, it is possible to embed a .net user control in an HTML page.
You have to use html Object tag, to do so.... as shown below.
classid="http://127.0.0.1/SampleControl.dll#Test.SampleControl">
Ritesh Kesharwani
SQL Star Intlernational Ltd.
Riteshk@sqlstarintl.com
Ritesh_kk2000@yahoo.com
www.Riteshk.blogspot.com
Cell - 9849976150
Yes, it is possible to embed a .net user control in an HTML page.
You have to use html Object tag, to do so.... as shown below.
classid="http://127.0.0.1/SampleControl.dll#Test.SampleControl">
Ritesh Kesharwani
SQL Star Intlernational Ltd.
Riteshk@sqlstarintl.com
Ritesh_kk2000@yahoo.com
www.Riteshk.blogspot.com
Cell - 9849976150
How to prevent Page being submitted when Enter key is pressed.
Hi,
Call This Function in onKeyPress event of any control.
function onKey()
{
if ((event.which && event.which == 13) (event.keyCode &&
event.keyCode == 13))
{document.myForm.myHtmlInputButton.click();return false;}
else return true;
}
for more detail you can go through with http://www.allasp.net/enterkey.aspx.
For All Page document.onkeypress = function(){return event.keyCode!=13;};
Regard's
Call This Function in onKeyPress event of any control.
function onKey()
{
if ((event.which && event.which == 13) (event.keyCode &&
event.keyCode == 13))
{document.myForm.myHtmlInputButton.click();return false;}
else return true;
}
for more detail you can go through with http://www.allasp.net/enterkey.aspx.
For All Page document.onkeypress = function(){return event.keyCode!=13;};
Regard's
Friday, July 23, 2004
How to change a WindowsApplicatioon project type to ConsoleApplic ation project type in visual studio
Hi All,
How to change a WindowsApplicatioon project type to ConsoleApplication
project type in visual studio?
Open "application.csproj" file in notepad, under "Settings" head change
OutputType = "winExe" to OutputType = "Exe".. that's it
How to change a WindowsApplicatioon project type to ConsoleApplication
project type in visual studio?
Open "application.csproj" file in notepad, under "Settings" head change
OutputType = "winExe" to OutputType = "Exe".. that's it
How to Disable ''Close' button in Window Form in .NET
Set ControlBox = false;
This will not show the 'Close' button.
This will not show the 'Close' button.
Thursday, July 22, 2004
How to Change Font Color and Size in Crystal Report on Run time
Public Sub setReportStyle(ByVal objReport As Object)
Dim intObjectCount As Integer
Try
intObjectCount = 0
'Checking whether report object is nothing or not
If Not Nothing Is objReport Then
'get all report sections into ReportSections variable
ReportSections = objReport.ReportDefinition.Sections
End If
If Not Nothing Is ReportSections Then
'Iterate through all sections
For Each Reportsection In ReportSections
'Iterate throw all fields in each section
For intObjectCount = 0 To Reportsection.ReportObjects.Count - 1
' for field type objects
If Reportsection.ReportObjects.Item(intObjectCount).Kind =
ReportObjectKind.FieldObject Then
fldObject = Reportsection.ReportObjects.Item(intObjectCount)
Dim strName As String
If Not Nothing Is fldObject Then
strName = fldObject.Name.ToLower
fldObject.ApplyFont(New Font("Arial", 12, FontStyle.Underline))
fldObject.Color = Color.Maroon
End if
Next
Next
End if
Catch ex as Exception
End Try
End sub
Dim intObjectCount As Integer
Try
intObjectCount = 0
'Checking whether report object is nothing or not
If Not Nothing Is objReport Then
'get all report sections into ReportSections variable
ReportSections = objReport.ReportDefinition.Sections
End If
If Not Nothing Is ReportSections Then
'Iterate through all sections
For Each Reportsection In ReportSections
'Iterate throw all fields in each section
For intObjectCount = 0 To Reportsection.ReportObjects.Count - 1
' for field type objects
If Reportsection.ReportObjects.Item(intObjectCount).Kind =
ReportObjectKind.FieldObject Then
fldObject = Reportsection.ReportObjects.Item(intObjectCount)
Dim strName As String
If Not Nothing Is fldObject Then
strName = fldObject.Name.ToLower
fldObject.ApplyFont(New Font("Arial", 12, FontStyle.Underline))
fldObject.Color = Color.Maroon
End if
Next
Next
End if
Catch ex as Exception
End Try
End sub
Wednesday, July 21, 2004
Creating the advertisement xml file using Adrotator Control (ASP. NET)
Hi
Fellow below step for make the images to be displayed in a timed fashion
There are two steps to using the AdRotator on your page: creating an
instance of the AdRotator web control on the page and creating the
advertisement xml file.
Creating an Instance of the AdRotator Web Control
The following code should be inserted on each aspx page you would like the
ad to appear on:
--------------------------------------------------------------------------
Thetag accepts the following properties:
* ID: The unique identifier for the AdRotator control.
* AdvertisementFile: The path of the advertisement file that contains
information about each ad.
* KeywordFilter: This property allows you to display ads based on a
keyword property that is set in the advertisement file.
That's about all it takes to add the AdRotator control to the page. Now
onto the Advertisement file.
Creating the Advertisement File
The advertisement file used by the AdRotator is a simple XML file that
should use the following format:
ads.xml
img1.jpg
http://www.gotothispage.com
This is alt text for the first ad
marbles
logo.gif
http://www.nogotothispage.com
This is alt text for the second ad
web development
-------------------------------------------------------------------------
The advertisement file consists of the following elements:
* This tag should surround all ads within your file.
This is called the root element.
* This tag contains all the attributes for a single ad within
your ad list.
* The path of the image file that will be displayed.
* The URL that the image file will link to.
* The ALT text for the image. This will be displayed
when a user hovers over the image or if the image can not be found.
* This is what the KeywordFilter property of the
tag searches for when filtering ads to display on a page.
* This property specifies the relative number of times
this ad compared to the other ads.
Regard's
Fellow below step for make the images to be displayed in a timed fashion
There are two steps to using the AdRotator on your page: creating an
instance of the AdRotator web control on the page and creating the
advertisement xml file.
Creating an Instance of the AdRotator Web Control
The following code should be inserted on each aspx page you would like the
ad to appear on:
--------------------------------------------------------------------------
The
information about each ad.
keyword property that is set in the advertisement file.
That's about all it takes to add the AdRotator control to the page. Now
onto the Advertisement file.
Creating the Advertisement File
The advertisement file used by the AdRotator is a simple XML file that
should use the following format:
ads.xml
The advertisement file consists of the following elements:
This is called the root element.
your ad list.
when a user hovers over the image or if the image can not be found.
this ad compared to the other ads.
Regard's
Tuesday, July 20, 2004
How to Lock the DeskTop in different Way ( Something New)
Hi,
This is a interesting piece of info that you can use to lock your
work-stations without using the combo key "CTRL- ALT- DEL"
If CTRL-ALT-DELETE seems like too much of a hassle, try this instead:
1. Right click an empty spot on the desktop, point to New and click
Shortcut.
2. In the Create Shortcut dialog box, type the following into the Type the
location of the item text box:
"rundll32 user32.dll,LockWorkStation" // remove quotes while typing
3. Click Next.
4. In the Select a Title for the Program dialog box, type "Lock Desktop" in
the Type a name for this shortcut text box.
5. Click Finish.
This is a interesting piece of info that you can use to lock your
work-stations without using the combo key "CTRL- ALT- DEL"
If CTRL-ALT-DELETE seems like too much of a hassle, try this instead:
1. Right click an empty spot on the desktop, point to New and click
Shortcut.
2. In the Create Shortcut dialog box, type the following into the Type the
location of the item text box:
"rundll32 user32.dll,LockWorkStation" // remove quotes while typing
3. Click Next.
4. In the Select a Title for the Program dialog box, type "Lock Desktop" in
the Type a name for this shortcut text box.
5. Click Finish.
Monday, July 19, 2004
How to do Encryption and Decryption using NET SHA1Managed class
Namapespace
Imports System.Security.Cryptography
C# Source Code
///
/// This function encript the string value using SHA notation
///
/// string value
///Encripted value
public static string GetEncryptedData(string data)
{
SHA1Managed shaManaged = new SHA1Managed();
string Enc_val =
Convert.ToBase64String(shaManaged.ComputeHash(Encoding.ASCII.GetBytes(data)));
byte[] enc_data = ASCIIEncoding.ASCII.GetBytes(data);
string enc_string = Convert.ToBase64String(enc_data);
return enc_string;
}
///
/// This function decript the encripted value using SHA notation
///
/// Encripted value
///stirng value
public static string GetDecryptedData(string data)
{
byte[] dec_data = Convert.FromBase64String(data);
string dsc_string = ASCIIEncoding.ASCII.GetString(dec_data);
return dsc_string;
}
VB Source Code
Public Function GetEncryptedData(ByVal Data As String) As String
'Dim shaM As New SHA1Managed
'Dim Enc_Password As String =
Convert.ToBase64String(shaM.ComputeHash(Encoding.ASCII.GetBytes((Data))))
'GetEncryptedData = Enc_Password
Dim eNC_data() As Byte =
System.Text.ASCIIEncoding.ASCII.GetBytes(Data)
Dim eNC_str As String = Convert.ToBase64String(eNC_data)
GetEncryptedData = eNC_str
End Function
Public Function GetDecryptedData(ByVal Data As String) As String
Dim dEC_data() As Byte = Convert.FromBase64String(Data)
'ConfigurationSettings.AppSettings
("connectionstring"))
Dim dEC_Str As String =
System.Text.ASCIIEncoding.ASCII.GetString(dEC_data)
GetDecryptedData = dEC_Str
End Function
How to use
Using these function you will get Encrypted and Decrypted form of data.
//return value would be "UHJvZHVjdElkPTEyMzQ1JkZpbGU9X05vYy54bWw="
string enc_value = GetEncryptedData('ProductId=12345&File=_Noc.xml');
//return value would be "ProductId=12345&File=_Noc.xml"
string dcrp_value = GetDecryptedData(enc_value);
Imports System.Security.Cryptography
C# Source Code
///
/// This function encript the string value using SHA notation
///
/// string value
///
public static string GetEncryptedData(string data)
{
SHA1Managed shaManaged = new SHA1Managed();
string Enc_val =
Convert.ToBase64String(shaManaged.ComputeHash(Encoding.ASCII.GetBytes(data)));
byte[] enc_data = ASCIIEncoding.ASCII.GetBytes(data);
string enc_string = Convert.ToBase64String(enc_data);
return enc_string;
}
///
/// This function decript the encripted value using SHA notation
///
/// Encripted value
///
public static string GetDecryptedData(string data)
{
byte[] dec_data = Convert.FromBase64String(data);
string dsc_string = ASCIIEncoding.ASCII.GetString(dec_data);
return dsc_string;
}
VB Source Code
Public Function GetEncryptedData(ByVal Data As String) As String
'Dim shaM As New SHA1Managed
'Dim Enc_Password As String =
Convert.ToBase64String(shaM.ComputeHash(Encoding.ASCII.GetBytes((Data))))
'GetEncryptedData = Enc_Password
Dim eNC_data() As Byte =
System.Text.ASCIIEncoding.ASCII.GetBytes(Data)
Dim eNC_str As String = Convert.ToBase64String(eNC_data)
GetEncryptedData = eNC_str
End Function
Public Function GetDecryptedData(ByVal Data As String) As String
Dim dEC_data() As Byte = Convert.FromBase64String(Data)
'ConfigurationSettings.AppSettings
("connectionstring"))
Dim dEC_Str As String =
System.Text.ASCIIEncoding.ASCII.GetString(dEC_data)
GetDecryptedData = dEC_Str
End Function
How to use
Using these function you will get Encrypted and Decrypted form of data.
//return value would be "UHJvZHVjdElkPTEyMzQ1JkZpbGU9X05vYy54bWw="
string enc_value = GetEncryptedData('ProductId=12345&File=_Noc.xml');
//return value would be "ProductId=12345&File=_Noc.xml"
string dcrp_value = GetDecryptedData(enc_value);
Saturday, July 17, 2004
How to display and edit Chinese on English Windows systems
Hai,
I searched for other resources. I came across a page, which would give you all the resources for your requirement
("How to display and edit Chinese on English Windows systems").
Please check over it.
("How to display and edit Chinese on English Windows systems").
Please check over it.
.NET Deployment Problem "keycodev2.dll"
Hi
A VB .NET web application uses Crystal Reports for Visual Studio .NET as the
reporting development tool.
When you run the application on the development computer, the following
error message appears:
"Cannot find keycodev2.dll or invalid keycode"
Why does this error message appear in this VB .NET web application?
====================
NOTE:
This issue only exists on the development computer when working with a web
application. This issue does not apply to deployment.
====================
Solution
This error message appears because the following registry keys do not have
rights for the ASPNET account:
- HKEY_CLASSES_ROOT\Interface\{4A4D268A-DF9B-4FC1-8301-D9FEEEF69F9C}
- HKEY_CLASSES_ROOT\TypeLib\{8D43D0B9-C14E-4577-9E67-A9A1EEF82302}
To resolve this error message, give these two registry keys ASPNET read
rights.
====================
NOTE:
To give ASPNET read rights to a registry key:
1. Go into the 32 bit Registry Editor (Start > Run > then type "regedt32").
2. Go to the 'HKEY_CLASSES_ROOT' window and select the 'Interface' key.
3. Highlight "{4A4D268A-DF9B-4FC1-8301-D9FEEEF69F9C}" and select the
"Security" menu then click "Permissions...".
4. In the permissions dialog, add the "ASPNET" account from the local
machine and give this account at least read rights.
Repeat steps 2 to 4, except use the "{8D43D0B9-C14E-4577-9E67-A9A1EEF82302}"
key under the "TypeLib" key.
====================
NOTE: After All above steps you have to Recompile your Program........
A VB .NET web application uses Crystal Reports for Visual Studio .NET as the
reporting development tool.
When you run the application on the development computer, the following
error message appears:
"Cannot find keycodev2.dll or invalid keycode"
Why does this error message appear in this VB .NET web application?
====================
NOTE:
This issue only exists on the development computer when working with a web
application. This issue does not apply to deployment.
====================
Solution
This error message appears because the following registry keys do not have
rights for the ASPNET account:
- HKEY_CLASSES_ROOT\Interface\{4A4D268A-DF9B-4FC1-8301-D9FEEEF69F9C}
- HKEY_CLASSES_ROOT\TypeLib\{8D43D0B9-C14E-4577-9E67-A9A1EEF82302}
To resolve this error message, give these two registry keys ASPNET read
rights.
====================
NOTE:
To give ASPNET read rights to a registry key:
1. Go into the 32 bit Registry Editor (Start > Run > then type "regedt32").
2. Go to the 'HKEY_CLASSES_ROOT' window and select the 'Interface' key.
3. Highlight "{4A4D268A-DF9B-4FC1-8301-D9FEEEF69F9C}" and select the
"Security" menu then click "Permissions...".
4. In the permissions dialog, add the "ASPNET" account from the local
machine and give this account at least read rights.
Repeat steps 2 to 4, except use the "{8D43D0B9-C14E-4577-9E67-A9A1EEF82302}"
key under the "TypeLib" key.
====================
NOTE: After All above steps you have to Recompile your Program........
Just Fun...
Hi
Once an old man was sitting in the park reading book "learn DOTNET in 21
days" A passer by saw him and asked "U are such an old guy, why do you
bother to learn DOTNET ?" "I have heard that communication language at
heaven is DOTNET so after my death when I will be in heaven, I don't want to
face communication problem." old man replied. " But how come are U so sure
that U will be in heaven? It could be a hell also." he asked. "Ya, doesn't
matter .... I already know COBOL"
Once an old man was sitting in the park reading book "learn DOTNET in 21
days" A passer by saw him and asked "U are such an old guy, why do you
bother to learn DOTNET ?" "I have heard that communication language at
heaven is DOTNET so after my death when I will be in heaven, I don't want to
face communication problem." old man replied. " But how come are U so sure
that U will be in heaven? It could be a hell also." he asked. "Ya, doesn't
matter .... I already know COBOL"
Thursday, July 15, 2004
Top 20 IT Software Exporters from India (2003-04)
TOP 20 IT SOFTWARE & SERVICE EXPORTERS FROM INDIA (2003-04)
Tata Consultancy Services
Infosys Technologies Ltd
Wipro Technologies
Satyam Computer Services Ltd
HCL Technologies Ltd
Patni Computer Systems Ltd
iFlex Solutions
Mahindra British Telecom Ltd
Polaris Software
Digital Globalsoft Ltd
NIIT Ltd
Perot Systems TSI (HCL Perot Systems Ltd)
iGATE Global Solutions Limited (Mascot Systems Ltd)
Birlasoft Ltd
Mphasis BFL Ltd
Mastek Ltd
Hexaware Technologies Ltd
Larsen & Toubro Infotech Ltd
Tata Consultancy Services
Infosys Technologies Ltd
Wipro Technologies
Satyam Computer Services Ltd
HCL Technologies Ltd
Patni Computer Systems Ltd
iFlex Solutions
Mahindra British Telecom Ltd
Polaris Software
Digital Globalsoft Ltd
NIIT Ltd
Perot Systems TSI (HCL Perot Systems Ltd)
iGATE Global Solutions Limited (Mascot Systems Ltd)
Birlasoft Ltd
Mphasis BFL Ltd
Mastek Ltd
Hexaware Technologies Ltd
Larsen & Toubro Infotech Ltd
Subscribe to:
Posts (Atom)