Showing posts with label rid. Show all posts
Showing posts with label rid. Show all posts

Wednesday, March 21, 2012

How to get table info from RID deadlock ?

Hi There

I am trying to troubleshoot deadlock issues.

The dead lock is with a RID.

Now from various links i have established that you have to use DBCC PAGE() with relevant info to get more information, i get back a object and index id, m_objid.

However i dont know how to get the tablename form here, msdn simply says that it is an allocation id not and actual table id, so how can i from here get to table information?

All i am trying to figure out is which table is affected fromt he RID dealock, but that does not seem to be a simple process.

Thanx

Anyone please ?

I have had the deadlock again:

Info is as follows:

RID 7,1, 6937169, 1

So i do the following to get the m_objid.

Dbcc traceon(3604)

Go

Dbcc page(7,1, 6937169, 0)

Once i have the m_objid , i do the following select object_name(m_objid), this returns null ?

Someone please tell me how on earth do you get the table name from the deadlock info involving a RID ?

Thanx

|||In SQL 2005, you can get the object id from Metadata: ObjectId when you execute the DBCC PAGE command.

Thanks,|||

Hi Marcel

I have already stated that, what i am asking is how do you get from the allocation object id provided by DBCC PAGE to a actual table name, select object_name(m_objid) , using the object id returned by DBCC PAGE returns null ?

|||My Apologies Marcel, i see you meant MetaData object id, that works, thanx a million.

How to get table info from RID deadlock ?

Hi There

I am trying to troubleshoot deadlock issues.

The dead lock is with a RID.

Now from various links i have established that you have to use DBCC PAGE() with relevant info to get more information, i get back a object and index id, m_objid.

However i dont know how to get the tablename form here, msdn simply says that it is an allocation id not and actual table id, so how can i from here get to table information?

All i am trying to figure out is which table is affected fromt he RID dealock, but that does not seem to be a simple process.

Thanx

Anyone please ?

I have had the deadlock again:

Info is as follows:

RID 7,1, 6937169, 1

So i do the following to get the m_objid.

Dbcc traceon(3604)

Go

Dbcc page(7,1, 6937169, 0)

Once i have the m_objid , i do the following select object_name(m_objid), this returns null ?

Someone please tell me how on earth do you get the table name from the deadlock info involving a RID ?

Thanx

|||In SQL 2005, you can get the object id from Metadata: ObjectId when you execute the DBCC PAGE command.

Thanks,|||

Hi Marcel

I have already stated that, what i am asking is how do you get from the allocation object id provided by DBCC PAGE to a actual table name, select object_name(m_objid) , using the object id returned by DBCC PAGE returns null ?

|||My Apologies Marcel, i see you meant MetaData object id, that works, thanx a million.

Monday, March 12, 2012

How to get rid of unused servers in SSMS?

In Connect to Server dialog box in SQL Server Management Studio, it has a drop-down box with a list previously connected servers. However, some of these servers are not used anymore. I want to get rid of them in order to make a room for new server names. So far I could not find a way how to do this, apparently SQL Server does not store these values in the Registry. Is there a way to get rid of them ?

Thanks.

I looked earlier today for you and like you it appears the registry is not the "store" for this data. Upon looking through all of the "known" sql directories my hunch (though I cannot find it) would be that its somewhere at C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE.|||

You can blow away all your Most Recently Used lists (including MRU connections) by deleting c:\Documents and Settings\<you>\Application Data\Microsoft SQL Server\90\Tools\Shell\mru.dat while Management Studio is not running. Management Studio will recreate the file the next time it starts.

Hope this helps,
Steve

How to get rid of time in a date/time field?

I am using vb.net 2005 with crystal and I am wanting to only show the date on the record being grabbed from SQL. currently it is showing the date along with the time stamp. Is there an easy way to do this in Crystal?I figured it out...format object :-) Easy enough!

How to get rid of the zeros in money type, Thanks!

How to get rid of the zeros in money type,

i.e. only show dollars, no cents?

I use:

CONVERT(varchar, Price, 1) AS Price

It gives me the result with 2 digits decimals. like 123,456.00

I only need the dollar part, how to get rid of the zeros, Thanks!

CONVERT(int, a) AS Price

CONVERT(numeric, a) AS Price

Also take a look at the following for CAST and CONVERT

http://msdn2.microsoft.com/en-us/library/ms187928.aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp

|||

Consider the functions CEILING() and FLOOR().

Zlatko

How to get rid of the GUID?

If I decide I don't want to use Queued Updating Subscribers, how do I get the replication guid's added off the tables in my database? A restore?
I am testing all my options, and have completed testing the use of queued updating, and want to move on to another option, but the guid's are causing me some problems, and I want to know if there is a sp to get rid of them or do I just need to restore my database?
Thanx!
JLS,
there is no sp to remove these columns. Usually there is no issue as TSQL is
writte using column names rather than columns by position. However, if you
have this sort of statement:
insert into tableX
select * from tableY
Then admittedly there will be issues.
You ask about restoring the database but I'm not too sure which one you are
referring to. If it is the production database and you are using replication
for failover, it would seem to be redundant?
Regards,
Paul Ibison

How to get rid of the Database Login window ?

Hi, I'm a newbie in VB.Net, need some help here. I'm generating a report and view it in a win app, which is in VB.Net. I've specified the database logon info by the following code:

*************************************************
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter
Dim crReportDocument As New cr1()
With crConnectionInfo
.ServerName = "mydb"
.UserID = "myuserid"
.Password = "mypassword"
End With

CrTables = crReportDocument.Database.Tables

For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next

CrystalReportViewer1.ReportSource = crReportDocument

End Sub
*****************************************************

It's an Oracle DB and just one table, suppose to be very simple. But whenever the app starts, this "Database Login" window always opens first, asking for server info, db info, user name and password. Actually if I click "Cancel", the report still get generated. So how to get rid of this annoying "Database Login" window?

My second question is, how to automatically send this report to printer? I know in VB6 you just say action=1. Unfortunately this thing doesn't work in .Net any more.

Thanks!Just look through CrystalReport knowledgebase, seems that this is a known issue. Refer to this article:
http://support.businessobjects.com/library/kbase/articles/c2010461.asp

Is there already a fix for this ?|||Figured this out by carefully reading this article: http://support.businessobjects.com/library/kbase/articles/c2010461.asp

The Form_new method has to be overwritten, adding some customized initialization, where ser/uid/pass can be specified.

**** I just took it for granted to do it in Form_load...

How To Get Rid Of Sql Log

Hi,
I have a Data base on Sql Server 2000, sp3a. Database is used to to build summary tables to show reports on web. There are many sub systems, which prepare summarized tables for faster web page serving. Every thing is working fine.

The problem is sql server log gets full. In one given day it could go up to 18 GB. I know, if I back it up it gets truncated. Is there a way, I can stop sql server not to log, as it is not needed?

Can I set up Sql server to automatically truncate it. I do have auto shrink options checked, but log file still keeps growing.

Any idea, what is going on here.
Thanks,
Mashro::Is there a way, I can stop sql server not to log, as it is not needed?

You err, it IS needed.

Read up in the documentation what the log is used for. It is needed.|||Back it up regularly to keep it from growing out of control. You can't eliminate the log. It's a pretty key piece of the puzzle. If you have the db set to simple recovery, it should truncate the log on each checkpoint. Probably no need to use a full recovery model on a 'derived' reporting database like you seem to have.

how to get RID of rows

thanks

Why exactly do you need the RID?

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

HI WesleyB

I have no concret need now.

Just want to know where it store?

I use dbcc page command to oversee the structure of the data page.

I can see many data row .... but can't see the RID....

|||The RID is not stored. It is calculated from the PageId and the SlotId on the page, i.e. Slot 17 on Page 1:29 has RID 1:29:17.

Thanks,

How to get rid of ONLY ONE publications?

I have got a Publisher with 5 different publications (different tables on each). One of them publicates only one table. I delete that one and then create a new one with the same table and a new table. My final purpose is adding a new table to an existing publication. When I run the merge agent, I got the error "cannot drop one or more tables because they are being used by another publications". I cannont use the sp sp_removedbreplication 'database_name' because I do not want to get rid of all of them, just "remake" one of the. The suscriber is the same for all and all of them are merge.
Thanks in advanced for your ideas.Use sp_droppublication and refer to books online for more information.

how to get rid of old records

I have a patient reviewing database
Master:
ID, Name, Address, etc.
Detail:
ID, Interviewing date, symptom, etc.

And I collect info monthly.
When I want to count how many patients have suffered from the symptom and classify them by period, which I only need the latest info, lots of old records of the same ID emerges. I am new in TSQL and have trouble in retrieving the up-to-date info. PL Help me!
Thank u.

Try this one:

declare @.symtom nvarchar(100)
set @.symtom = 'headache'

select
count(distinct ID) as count,
year([Interviewing date]) as year,
month([Interviewing date]) as month
from Detail
where symptom = @.symtom
group by year([Interviewing date]), month([Interviewing date])

How to get rid of Ghost Pages

For those of you who may not have heard of ghost pages, when SQL Server
deletes all the rows in a data page, it doesn't re-use it untill a seperate
process cleans up such pages. These pages are called ghost pages.
I have a SQL7 production database where the process to clean up the ghost
pages is not waking up. I just read some where that there is a trace that ca
n
be turned on in order to stop this process from waking up. Can someone pleas
e
tell me what the trace number is that I can turn off?
Here are some more details... I have a table in production that is used as
"scratch pad" and therefore encounters a lot of inserts/deletes. The table a
t
any given time will have a couple of rows to may be a couple of hundred rows
.
Over time, the number of ghost pages increase and the SQLs doing joins
against this table treat it as if it has a lot of rows and as a result, the
underlying query plan changes and causes the SQLs to run for a long time.
Here is the interesting part... I noticed at one point there were only a
couple of rows in the table and the number of data pages showing up in DBCC
SHOWCONTIG output where in hundreds and the extent fragmentation was very
high. Also, in some cases, every data page was in a different extent even
though the table only had a couple of rows. When I created a clustered index
and droped the index, the ghost pages disappeared and made a day and night
difference in performance. When I left the clustered index on the table, the
ghost pages eventually appeared again. From that point onwards, when I
dropped and re-created the clustered index, the ghost pages disappeared one
more time and the underlying SQLs started running much faster again.
Does anyone know of a permenant fix to this?
Thanks.
AdamCan you post the list of trace flags that you have on?
Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine
http://blogs.msdn.com/sqlserverstor...ne/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
"Adam" <Adam@.discussions.microsoft.com> wrote in message
news:6DB63A27-CBE7-49E3-9AD7-B61C1BD49C53@.microsoft.com...
> For those of you who may not have heard of ghost pages, when SQL Server
> deletes all the rows in a data page, it doesn't re-use it untill a
> seperate
> process cleans up such pages. These pages are called ghost pages.
> I have a SQL7 production database where the process to clean up the ghost
> pages is not waking up. I just read some where that there is a trace that
> can
> be turned on in order to stop this process from waking up. Can someone
> please
> tell me what the trace number is that I can turn off?
> Here are some more details... I have a table in production that is used
> as
> "scratch pad" and therefore encounters a lot of inserts/deletes. The table
> at
> any given time will have a couple of rows to may be a couple of hundred
> rows.
> Over time, the number of ghost pages increase and the SQLs doing joins
> against this table treat it as if it has a lot of rows and as a result,
> the
> underlying query plan changes and causes the SQLs to run for a long time.
> Here is the interesting part... I noticed at one point there were only a
> couple of rows in the table and the number of data pages showing up in
> DBCC
> SHOWCONTIG output where in hundreds and the extent fragmentation was very
> high. Also, in some cases, every data page was in a different extent even
> though the table only had a couple of rows. When I created a clustered
> index
> and droped the index, the ghost pages disappeared and made a day and night
> difference in performance. When I left the clustered index on the table,
> the
> ghost pages eventually appeared again. From that point onwards, when I
> dropped and re-created the clustered index, the ghost pages disappeared
> one
> more time and the underlying SQLs started running much faster again.
> Does anyone know of a permenant fix to this?
> Thanks.
> Adam

How to get rid of Ghost Pages

For those of you who may not have heard of ghost pages, when SQL Server
deletes all the rows in a data page, it doesn't re-use it untill a seperate
process cleans up such pages. These pages are called ghost pages.
I have a SQL7 production database where the process to clean up the ghost
pages is not waking up. I just read some where that there is a trace that can
be turned on in order to stop this process from waking up. Can someone please
tell me what the trace number is that I can turn off?
Here are some more details... I have a table in production that is used as
"scratch pad" and therefore encounters a lot of inserts/deletes. The table at
any given time will have a couple of rows to may be a couple of hundred rows.
Over time, the number of ghost pages increase and the SQLs doing joins
against this table treat it as if it has a lot of rows and as a result, the
underlying query plan changes and causes the SQLs to run for a long time.
Here is the interesting part... I noticed at one point there were only a
couple of rows in the table and the number of data pages showing up in DBCC
SHOWCONTIG output where in hundreds and the extent fragmentation was very
high. Also, in some cases, every data page was in a different extent even
though the table only had a couple of rows. When I created a clustered index
and droped the index, the ghost pages disappeared and made a day and night
difference in performance. When I left the clustered index on the table, the
ghost pages eventually appeared again. From that point onwards, when I
dropped and re-created the clustered index, the ghost pages disappeared one
more time and the underlying SQLs started running much faster again.
Does anyone know of a permenant fix to this?
Thanks.
Adam
Can you post the list of trace flags that you have on?
Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine
http://blogs.msdn.com/sqlserverstorageengine/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
"Adam" <Adam@.discussions.microsoft.com> wrote in message
news:6DB63A27-CBE7-49E3-9AD7-B61C1BD49C53@.microsoft.com...
> For those of you who may not have heard of ghost pages, when SQL Server
> deletes all the rows in a data page, it doesn't re-use it untill a
> seperate
> process cleans up such pages. These pages are called ghost pages.
> I have a SQL7 production database where the process to clean up the ghost
> pages is not waking up. I just read some where that there is a trace that
> can
> be turned on in order to stop this process from waking up. Can someone
> please
> tell me what the trace number is that I can turn off?
> Here are some more details... I have a table in production that is used
> as
> "scratch pad" and therefore encounters a lot of inserts/deletes. The table
> at
> any given time will have a couple of rows to may be a couple of hundred
> rows.
> Over time, the number of ghost pages increase and the SQLs doing joins
> against this table treat it as if it has a lot of rows and as a result,
> the
> underlying query plan changes and causes the SQLs to run for a long time.
> Here is the interesting part... I noticed at one point there were only a
> couple of rows in the table and the number of data pages showing up in
> DBCC
> SHOWCONTIG output where in hundreds and the extent fragmentation was very
> high. Also, in some cases, every data page was in a different extent even
> though the table only had a couple of rows. When I created a clustered
> index
> and droped the index, the ghost pages disappeared and made a day and night
> difference in performance. When I left the clustered index on the table,
> the
> ghost pages eventually appeared again. From that point onwards, when I
> dropped and re-created the clustered index, the ghost pages disappeared
> one
> more time and the underlying SQLs started running much faster again.
> Does anyone know of a permenant fix to this?
> Thanks.
> Adam

how to get rid of free db spaces on sql sever 7

I have a SQL Server 7 and after I shrank one of the databases, I got 14 gb of
free spaces. How to get rid of the extra free spaces on Version 7 of SQL
Server environment?DBCC SHRINKDATABASE or DBCC SHRINKFILE
With version 7.0, however, you will have a heck of a time shrinking the log
file. If you can not get it to shrink as far as you would like, detach the
database, then move the log file somewhere else, and use the
sp_attach_single_file_db. This should regenerate a new log file, but using
the model database as a template instead of the old one.
Sincerely,
Anthony Thomas
"GR" wrote:
> I have a SQL Server 7 and after I shrank one of the databases, I got 14 gb of
> free spaces. How to get rid of the extra free spaces on Version 7 of SQL
> Server environment?
>

how to get rid of free db spaces on sql sever 7

I have a SQL Server 7 and after I shrank one of the databases, I got 14 gb o
f
free spaces. How to get rid of the extra free spaces on Version 7 of SQL
Server environment?DBCC SHRINKDATABASE or DBCC SHRINKFILE
With version 7.0, however, you will have a heck of a time shrinking the log
file. If you can not get it to shrink as far as you would like, detach the
database, then move the log file somewhere else, and use the
sp_attach_single_file_db. This should regenerate a new log file, but using
the model database as a template instead of the old one.
Sincerely,
Anthony Thomas
"GR" wrote:

> I have a SQL Server 7 and after I shrank one of the databases, I got 14 gb
of
> free spaces. How to get rid of the extra free spaces on Version 7 of SQL
> Server environment?
>

how to get rid of free db spaces on sql sever 7

I have a SQL Server 7 and after I shrank one of the databases, I got 14 gb of
free spaces. How to get rid of the extra free spaces on Version 7 of SQL
Server environment?
DBCC SHRINKDATABASE or DBCC SHRINKFILE
With version 7.0, however, you will have a heck of a time shrinking the log
file. If you can not get it to shrink as far as you would like, detach the
database, then move the log file somewhere else, and use the
sp_attach_single_file_db. This should regenerate a new log file, but using
the model database as a template instead of the old one.
Sincerely,
Anthony Thomas
"GR" wrote:

> I have a SQL Server 7 and after I shrank one of the databases, I got 14 gb of
> free spaces. How to get rid of the extra free spaces on Version 7 of SQL
> Server environment?
>

How to get rid of duplicates in the table

I have a table which has quite a few duplicates and I cannot create unique
index on it.
First I want to list those duplicate so I can do something about it and
secondly, I want to delete them so I can create index.
Thanks
Mac,
Please post the DDL including sample data.
Thanks
Jerry
"Mac" <msamani@.comcast.net> wrote in message
news:e9Auq1l1FHA.3524@.tk2msftngp13.phx.gbl...
>I have a table which has quite a few duplicates and I cannot create unique
>index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>
|||Mac,
Build an index and do a select out all rows and add GROUP BY <COL>
HAVING COUNT(*) > 1. You will then get the rows which are duplicate
based on the <COL>. You can certainly add <COL1>, <COL2>. Then
remove/modify the rows and you should be able to build a unique index.
Be aware you need to do this when the system is quiet otherwise you can
have extra duplicates occur. Also your applicatio may need to be
updated to deal with a UNIQUE index collission.
Shahryar
Mac wrote:

>I have a table which has quite a few duplicates and I cannot create unique
>index on it.
>First I want to list those duplicate so I can do something about it and
>secondly, I want to delete them so I can create index.
>Thanks
>
>
Shahryar G. Hashemi | Sr. DBA Consultant
InfoSpace, Inc.
601 108th Ave NE | Suite 1200 | Bellevue, WA 98004 USA
Mobile +1 206.459.6203 | Office +1 425.201.8853 | Fax +1 425.201.6150
shashem@.infospace.com | www.infospaceinc.com
This e-mail and any attachments may contain confidential information that is legally privileged. The information is solely for the use of the intended recipient(s); any disclosure, copying, distribution, or other use of this information is strictly prohi
bited. If you have received this e-mail in error, please notify the sender by return e-mail and delete this message. Thank you.
|||Put an identity on the table
group by your fields and Max identity value, insert that into another table
delete everything from orig table where identity is not in the other table
drop identity
create index
http://sqlservercode.blogspot.com/
"Mac" wrote:

> I have a table which has quite a few duplicates and I cannot create unique
> index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>
>
|||Hi Mac.
This is a 4 step solution. First you have to move all dups into a new table,
lets call TEMP_TAB. Second delete all dups from your master table, lets call
TAB_WITH_DUPS. Third move all records from TEMP_TAB to TAB_WITH_DUPS. Forth
dropTEMP_TAB.
For your understanding check following out.
-- STEP 0 - Preparing for the test
CREATE TABLE TAB_WITH_DUPS (COL_1 VARCHAR(10), COL_2 VARCHAR(10), COL_3
VARCHAR(10), )
INSERT INTO TAB_WITH_DUPS VALUES ('AA', 'BB', 'CC')
INSERT INTO TAB_WITH_DUPS VALUES ('AA', 'BB', 'CC')
INSERT INTO TAB_WITH_DUPS VALUES ('BB', 'BB', 'AA')
INSERT INTO TAB_WITH_DUPS VALUES ('CC', 'BB', 'CC')
SELECT * FROM TAB_WITH_DUPS
-- STEP 1 - Move dups to a new table
SELECT
DISTINCT
COL_1,
COL_2,
COL_3
INTO
TEMP_TAB
FROM
TAB_WITH_DUPS
GROUP BY
COL_1,
COL_2,
COL_3
HAVING
COUNT(*) > 1
SELECT * FROM TEMP_TAB
-- STEP 2 - Delete dups from the master table
DELETE a
FROM TAB_WITH_DUPS a
INNER JOIN TEMP_TAB b
ON a.COL_1 = b.COL_1
AND a.COL_2 = b.COL_2
AND a.COL_3 = b.COL_3
SELECT * FROM TAB_WITH_DUPS
-- STEP 3 - Bring data back to the master table.
INSERT INTO TAB_WITH_DUPS SELECT * FROM TEMP_TAB
SELECT * FROM TAB_WITH_DUPS
-- STEP 4 - Get rid of the newly created table
DROP TABLE TEMP_TAB
"Mac" wrote:

> I have a table which has quite a few duplicates and I cannot create unique
> index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>
>
|||I believe this is a simpler method:
1. SELECT * INTO #Temp1 FROM [TableName]
2. TRUNCATE TABLE [TableName]
3. CREATE UNIQUE INDEX [IndexName] ON [TableName] (ColumnNames] WITH
IGNORE_DUP_KEY
4. INSERT INTO [TableName] (ColumnNames)
SELECT (ColumnNames)
FROM #Temp1
Mike

How to get rid of duplicates in the table

I have a table which has quite a few duplicates and I cannot create unique
index on it.
First I want to list those duplicate so I can do something about it and
secondly, I want to delete them so I can create index.
ThanksMac,
Please post the DDL including sample data.
Thanks
Jerry
"Mac" <msamani@.comcast.net> wrote in message
news:e9Auq1l1FHA.3524@.tk2msftngp13.phx.gbl...
>I have a table which has quite a few duplicates and I cannot create unique
>index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>|||Mac,
Build an index and do a select out all rows and add GROUP BY <COL>
HAVING COUNT(*) > 1. You will then get the rows which are duplicate
based on the <COL>. You can certainly add <COL1>, <COL2>. Then
remove/modify the rows and you should be able to build a unique index.
Be aware you need to do this when the system is quiet otherwise you can
have extra duplicates occur. Also your applicatio may need to be
updated to deal with a UNIQUE index collission.
Shahryar
Mac wrote:

>I have a table which has quite a few duplicates and I cannot create unique
>index on it.
>First I want to list those duplicate so I can do something about it and
>secondly, I want to delete them so I can create index.
>Thanks
>
>
Shahryar G. Hashemi | Sr. DBA Consultant
InfoSpace, Inc.
601 108th Ave NE | Suite 1200 | Bellevue, WA 98004 USA
Mobile +1 206.459.6203 | Office +1 425.201.8853 | Fax +1 425.201.6150
shashem@.infospace.com | www.infospaceinc.com
This e-mail and any attachments may contain confidential information that is
legally privileged. The information is solely for the use of the intended
recipient(s); any disclosure, copying, distribution, or other use of this in
formation is strictly prohi
bited. If you have received this e-mail in error, please notify the sender
by return e-mail and delete this message. Thank you.|||Put an identity on the table
group by your fields and Max identity value, insert that into another table
delete everything from orig table where identity is not in the other table
drop identity
create index
http://sqlservercode.blogspot.com/
"Mac" wrote:

> I have a table which has quite a few duplicates and I cannot create unique
> index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>
>|||Hi Mac.
This is a 4 step solution. First you have to move all dups into a new table,
lets call TEMP_TAB. Second delete all dups from your master table, lets call
TAB_WITH_DUPS. Third move all records from TEMP_TAB to TAB_WITH_DUPS. Forth
dropTEMP_TAB.
For your understanding check following out.
---
-- STEP 0 - Preparing for the test
---
CREATE TABLE TAB_WITH_DUPS (COL_1 VARCHAR(10), COL_2 VARCHAR(10), COL_3
VARCHAR(10), )
INSERT INTO TAB_WITH_DUPS VALUES ('AA', 'BB', 'CC')
INSERT INTO TAB_WITH_DUPS VALUES ('AA', 'BB', 'CC')
INSERT INTO TAB_WITH_DUPS VALUES ('BB', 'BB', 'AA')
INSERT INTO TAB_WITH_DUPS VALUES ('CC', 'BB', 'CC')
SELECT * FROM TAB_WITH_DUPS
---
-- STEP 1 - Move dups to a new table
---
SELECT
DISTINCT
COL_1,
COL_2,
COL_3
INTO
TEMP_TAB
FROM
TAB_WITH_DUPS
GROUP BY
COL_1,
COL_2,
COL_3
HAVING
COUNT(*) > 1
SELECT * FROM TEMP_TAB
---
-- STEP 2 - Delete dups from the master table
---
DELETE a
FROM TAB_WITH_DUPS a
INNER JOIN TEMP_TAB b
ON a.COL_1 = b.COL_1
AND a.COL_2 = b.COL_2
AND a.COL_3 = b.COL_3
SELECT * FROM TAB_WITH_DUPS
---
-- STEP 3 - Bring data back to the master table.
---
INSERT INTO TAB_WITH_DUPS SELECT * FROM TEMP_TAB
SELECT * FROM TAB_WITH_DUPS
---
-- STEP 4 - Get rid of the newly created table
---
DROP TABLE TEMP_TAB
"Mac" wrote:

> I have a table which has quite a few duplicates and I cannot create unique
> index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>
>|||I believe this is a simpler method:
1. SELECT * INTO #Temp1 FROM [TableName]
2. TRUNCATE TABLE [TableName]
3. CREATE UNIQUE INDEX [IndexName] ON [TableName] (ColumnNames] WITH
IGNORE_DUP_KEY
4. INSERT INTO [TableName] (ColumnNames)
SELECT (ColumnNames)
FROM #Temp1
Mike

How to get rid of duplicates in the table

I have a table which has quite a few duplicates and I cannot create unique
index on it.
First I want to list those duplicate so I can do something about it and
secondly, I want to delete them so I can create index.
ThanksMac,
Please post the DDL including sample data.
Thanks
Jerry
"Mac" <msamani@.comcast.net> wrote in message
news:e9Auq1l1FHA.3524@.tk2msftngp13.phx.gbl...
>I have a table which has quite a few duplicates and I cannot create unique
>index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>|||Mac,
Build an index and do a select out all rows and add GROUP BY <COL>
HAVING COUNT(*) > 1. You will then get the rows which are duplicate
based on the <COL>. You can certainly add <COL1>, <COL2>. Then
remove/modify the rows and you should be able to build a unique index.
Be aware you need to do this when the system is quiet otherwise you can
have extra duplicates occur. Also your applicatio may need to be
updated to deal with a UNIQUE index collission.
Shahryar
Mac wrote:
>I have a table which has quite a few duplicates and I cannot create unique
>index on it.
>First I want to list those duplicate so I can do something about it and
>secondly, I want to delete them so I can create index.
>Thanks
>
>
Shahryar G. Hashemi | Sr. DBA Consultant
InfoSpace, Inc.
601 108th Ave NE | Suite 1200 | Bellevue, WA 98004 USA
Mobile +1 206.459.6203 | Office +1 425.201.8853 | Fax +1 425.201.6150
shashem@.infospace.com | www.infospaceinc.com
This e-mail and any attachments may contain confidential information that is legally privileged. The information is solely for the use of the intended recipient(s); any disclosure, copying, distribution, or other use of this information is strictly prohibited. If you have received this e-mail in error, please notify the sender by return e-mail and delete this message. Thank you.|||Put an identity on the table
group by your fields and Max identity value, insert that into another table
delete everything from orig table where identity is not in the other table
drop identity
create index
http://sqlservercode.blogspot.com/
"Mac" wrote:
> I have a table which has quite a few duplicates and I cannot create unique
> index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>
>|||Hi Mac.
This is a 4 step solution. First you have to move all dups into a new table,
lets call TEMP_TAB. Second delete all dups from your master table, lets call
TAB_WITH_DUPS. Third move all records from TEMP_TAB to TAB_WITH_DUPS. Forth
dropTEMP_TAB.
For your understanding check following out.
---
-- STEP 0 - Preparing for the test
---
CREATE TABLE TAB_WITH_DUPS (COL_1 VARCHAR(10), COL_2 VARCHAR(10), COL_3
VARCHAR(10), )
INSERT INTO TAB_WITH_DUPS VALUES ('AA', 'BB', 'CC')
INSERT INTO TAB_WITH_DUPS VALUES ('AA', 'BB', 'CC')
INSERT INTO TAB_WITH_DUPS VALUES ('BB', 'BB', 'AA')
INSERT INTO TAB_WITH_DUPS VALUES ('CC', 'BB', 'CC')
SELECT * FROM TAB_WITH_DUPS
---
-- STEP 1 - Move dups to a new table
---
SELECT
DISTINCT
COL_1,
COL_2,
COL_3
INTO
TEMP_TAB
FROM
TAB_WITH_DUPS
GROUP BY
COL_1,
COL_2,
COL_3
HAVING
COUNT(*) > 1
SELECT * FROM TEMP_TAB
---
-- STEP 2 - Delete dups from the master table
---
DELETE a
FROM TAB_WITH_DUPS a
INNER JOIN TEMP_TAB b
ON a.COL_1 = b.COL_1
AND a.COL_2 = b.COL_2
AND a.COL_3 = b.COL_3
SELECT * FROM TAB_WITH_DUPS
---
-- STEP 3 - Bring data back to the master table.
---
INSERT INTO TAB_WITH_DUPS SELECT * FROM TEMP_TAB
SELECT * FROM TAB_WITH_DUPS
---
-- STEP 4 - Get rid of the newly created table
---
DROP TABLE TEMP_TAB
"Mac" wrote:
> I have a table which has quite a few duplicates and I cannot create unique
> index on it.
> First I want to list those duplicate so I can do something about it and
> secondly, I want to delete them so I can create index.
> Thanks
>
>|||I believe this is a simpler method:
1. SELECT * INTO #Temp1 FROM [TableName]
2. TRUNCATE TABLE [TableName]
3. CREATE UNIQUE INDEX [IndexName] ON [TableName] (ColumnNames] WITH
IGNORE_DUP_KEY
4. INSERT INTO [TableName] (ColumnNames)
SELECT (ColumnNames)
FROM #Temp1
Mike

how to get rid of document map in reports

there is a tree on the left hand side of my report ,which I don't want it to
be there ,how can I hide that document map? is there a special paramter or
somehting that I have to pass?
thanks for yuor help.
ALIData regions (matrix, table, list, etc.), groupings (except chart groups
where Labels have a different meaning), and textboxes have a property called
Label. If the Label property is set on any of these and the expression
returns a value != null, the document map will show up.
You can open an RDL file in a XML editor, report designer code view, or
notepad and just search for <Label> elements and remove them if you don't
want them. However, make sure to *not* remove <Label> elements on report
parameters or on chart groupings (because these are the labels shown inside
the chart).
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"ALI-R" <newbie@.microsoft.com> wrote in message
news:%23IuNuXl3EHA.3504@.TK2MSFTNGP12.phx.gbl...
> there is a tree on the left hand side of my report ,which I don't want it
to
> be there ,how can I hide that document map? is there a special paramter
or
> somehting that I have to pass?
> thanks for yuor help.
> ALI
>|||thanks for the information.now it is working
"Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
news:u$bxhdl3EHA.3504@.TK2MSFTNGP12.phx.gbl...
> Data regions (matrix, table, list, etc.), groupings (except chart groups
> where Labels have a different meaning), and textboxes have a property
called
> Label. If the Label property is set on any of these and the expression
> returns a value != null, the document map will show up.
> You can open an RDL file in a XML editor, report designer code view, or
> notepad and just search for <Label> elements and remove them if you don't
> want them. However, make sure to *not* remove <Label> elements on report
> parameters or on chart groupings (because these are the labels shown
inside
> the chart).
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> "ALI-R" <newbie@.microsoft.com> wrote in message
> news:%23IuNuXl3EHA.3504@.TK2MSFTNGP12.phx.gbl...
> > there is a tree on the left hand side of my report ,which I don't want
it
> to
> > be there ,how can I hide that document map? is there a special
paramter
> or
> > somehting that I have to pass?
> >
> > thanks for yuor help.
> > ALI
> >
> >
>