Following code is used to find duplicate rows in a Table, which doesn't have primary key. You can use either GROUP clause or HAVING clause to get all duplicate rows.
HAVING Clause:
SELECT COLUMN_NAME
FROM TABLENAME
GROUP BY COLUMN_NAME
HAVING COUNT(*) >1
GROUP BY Clause:
SELECT * FROM (
SELECT COLUMN_NAME, COUNT(COLUMN_NAME) AS CNT
FROM TABLENAME
GROUP BY COLUMN_NAME) AS A
WHERE CNT>1
....Dare 2 Dream - Success is not final, failure is not fatal: it is the courage to continue that counts.
"None can stop the rising sun, clouds can hide for a while........" -Ravi
Tuesday, February 16, 2010
Monday, October 5, 2009
Enable version settings in a SharePoint list
You can enable Version Settings for SharePoint lists so that they track versions of the items they contain. You can specify the number of versions to track and also view prior versions of items in the list. When version tracking is enabled for the list, each time the data in a row changes, Windows SharePoint Services creates a new version of that row.
To enable version tracking, you need the Manage Lists permission on the Windows SharePoint Services server. If you are not able to change the version settings, Check with your SharePoint Site adminstrator about your permisions.
To enable version tracking, you need the Manage Lists permission on the Windows SharePoint Services server. If you are not able to change the version settings, Check with your SharePoint Site adminstrator about your permisions.
- Go to the List and click on Settings
- On the Settings menu , click List Settings
- Under General Settings, click Versioning settings.
- On the List Versioning Settings page, in the Item Version History section, under Create a version each time you edit an item in this list?, click Yes.
- To limit the number of versions to retain, select Keep the following number of versions, and then type the number of versions to retain.(If you limits the number of versions that it stores, the oldest versions are permanently deleted when the limit is reached. They are not sent to the Recycle, So need to make sure do you need old versions or not)
Show/Hide "Create Folder" in Lists in SharePoint
This article explains how to Show or Hide New Folder options in lists or documents in SharePoint.
When created a List(Lists can be documents, project task, e.t.c) in the Sharepoint, by default it will give the option Create Folder under New task under that list. For hiding the Create New Folder option, First, you should be owner to the site and then follow the following steps..
When created a List(Lists can be documents, project task, e.t.c) in the Sharepoint, by default it will give the option Create Folder under New task under that list. For hiding the Create New Folder option, First, you should be owner to the site and then follow the following steps..
- Go to the List
- Click on Settings
- Select List Settings
- Click on Advanced Settings, Which is under genaral setting
- Check "NO" option for - Display "New Folder" command on the New menu?
Wednesday, September 23, 2009
Maintain Scroll Position in ASP.NET 2.0
This article explains, how to maintain current page scroll position across page postback events.
When working with large data in gridview, Scroll down the page and doing some thing that causes a postback, Then page automatically set back to the top position rather than staying at the current scroll position.
Smartnavigation (Smartnavigation = true) feature was using in .NET 1.X frame work. But It had only worked in IE browser.
It has been resolved in .NET 2.0 by using MaintainScrollPositionOnPostback page directive attribute.
This attribute can add to the pages in three ways.
1) Set Globally ( Set it in Web.Config in root level)
<system.web>
<pages theme="DefaultSkin" maintainScrollPositionOnPostBack="true" >
</pages>
</system.web>
2) Page Level Scrolling Mainatanance
In ASP.NET Page:
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" %>
3) Set in Programatically:
Import the Name space System.Web.UI, like in C#:
using System.Web.UI;
Set MaintainScrollPositionOnPostback true in Page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Page.MaintainScrollPositionOnPostBack = true;
}
}
When working with large data in gridview, Scroll down the page and doing some thing that causes a postback, Then page automatically set back to the top position rather than staying at the current scroll position.
Smartnavigation (Smartnavigation = true) feature was using in .NET 1.X frame work. But It had only worked in IE browser.
It has been resolved in .NET 2.0 by using MaintainScrollPositionOnPostback page directive attribute.
This attribute can add to the pages in three ways.
1) Set Globally ( Set it in Web.Config in root level)
<system.web>
<pages theme="DefaultSkin" maintainScrollPositionOnPostBack="true" >
</pages>
</system.web>
2) Page Level Scrolling Mainatanance
In ASP.NET Page:
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" %>
3) Set in Programatically:
Import the Name space System.Web.UI, like in C#:
using System.Web.UI;
Set MaintainScrollPositionOnPostback true in Page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Page.MaintainScrollPositionOnPostBack = true;
}
}
Thursday, August 27, 2009
Using windows MessageBox in ASP.NET
I have seen in the forums, lot of people are asking for using Windows MessageBox in ASP.NET. It's pretty simple. Just you need to Add System.Windows.Forms namespace to references. Follow these steps:
1) Right Click on References in your solution explorer
2) Click on Add References. Add References window will be open
3) Under .NET tab select System.Windows.Forms, Click Ok. Now it added to your reference library
4) Import the namespace System.Windows.Forms in your page
C#: using System.Windows.Forms;
VB.NET: Import System.Windows.Forms
5) Now you can use MessageBox.Show();
1) Right Click on References in your solution explorer
2) Click on Add References. Add References window will be open
3) Under .NET tab select System.Windows.Forms, Click Ok. Now it added to your reference library
4) Import the namespace System.Windows.Forms in your page
C#: using System.Windows.Forms;
VB.NET: Import System.Windows.Forms
5) Now you can use MessageBox.Show();
Thursday, August 20, 2009
Ceating Indexes on views in SQL 2005
When I was creating Index on view, I got the following error.
"Cannot create index on view 'v_testview' because the view is not schema bound. (Microsoft SQL Server, Error: 1939)". Following link helped me to figure out the solution.
http://www.mssqltips.com/tip.asp?tip=1610
It may hellpfull to you also..
"Cannot create index on view 'v_testview' because the view is not schema bound. (Microsoft SQL Server, Error: 1939)". Following link helped me to figure out the solution.
http://www.mssqltips.com/tip.asp?tip=1610
It may hellpfull to you also..
Saturday, August 8, 2009
Restore existing database in SQL 2005
1)Open Microsoft SQL Server Studio, Login with your SQL Credentials or using Windows Authentication mode.
2)Create New Database with name “DatabaseName”, Set path for MDF and LDF files on your local computer.
3) Right click on the created databse("DatabaseName") in Object Browser Window and select Task->Restore->Database option. You will get restore database wizard opened.
4) On General Menu, select radio option of “From Device”, then select backup file from browse file option.
5) After successfully selection of Backup file, Goto Options menu from left navigation pane and Mark “Overwrite Existing Database” to true.
6) Click OK
If you want to create database diagrams for restored database, you will get the following error.
Error: Database Diagram Support Objects cann't be installed because this database doesn't have a valid owner.

Solution: By default restored database consider system login ID as database owner. We need to change the database ownership manually, back to the owner that originally created the database when diagrams created. To accomplish this run the following query in SQL query analyzer
--Replace "DatabaseName" with your database name
USE DatabaseName--(change this Database name)
GO
--Following query will change owner name
EXEC sp_changedbowner 'sa';
GO
You can look at the current wner to the database by running the following query
EXEC sp_helpdb;
GO
2)Create New Database with name “DatabaseName”, Set path for MDF and LDF files on your local computer.
3) Right click on the created databse("DatabaseName") in Object Browser Window and select Task->Restore->Database option. You will get restore database wizard opened.
4) On General Menu, select radio option of “From Device”, then select backup file from browse file option.
5) After successfully selection of Backup file, Goto Options menu from left navigation pane and Mark “Overwrite Existing Database” to true.
6) Click OK
If you want to create database diagrams for restored database, you will get the following error.
Error: Database Diagram Support Objects cann't be installed because this database doesn't have a valid owner.

Solution: By default restored database consider system login ID as database owner. We need to change the database ownership manually, back to the owner that originally created the database when diagrams created. To accomplish this run the following query in SQL query analyzer
--Replace "DatabaseName" with your database name
USE DatabaseName--(change this Database name)
GO
--Following query will change owner name
EXEC sp_changedbowner 'sa';
GO
You can look at the current wner to the database by running the following query
EXEC sp_helpdb;
GO
Subscribe to:
Posts (Atom)