|
|
Please don't cross post and please don't put Urgent in the title.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Cheers.;)
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You say "dont" he says "will do" and you say "cheers"?? Fun language this...
|
|
|
|
|
I have a table, that has an Identity Column as a Primary key.Suddenly there are some Dublicate that have same idenitity Column ID, and they look identical. i cant remove the Duplicates because they have the same ID. please help me to remove the Duplicate.
thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hmmm. Did you remove the unique constraint from your primary key field by any chance (the identity column is a primary key, isn't it)? This constraint is there to ensure that you can't have duplicate fields.
Anyway, there are a number of ways that you could do this, but the implementation really depends on factors such as do you have foreign keys linked to your table? If so, then you really need to be careful about deleting.
A quick thought has occurred to me - how did you select these records? Are they part of a multi-table select? If so, it is likely that what you are seeing is the result of a one-to-many relationship. Try selecting the data out of the table on its own.
If a single table select still produces duplicate data and it's not a part of a foreign key then you can do the following:
Open up your table in the designer and drop the identity column. Save it to the database. Then add the identity column back into the table and save it again. The stages here drop the identity column and then force the database to apply a new identity column - which will have the effect of giving a new Id to each record. Voila - you now have unique rows.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Thanks for your reply
i did not remove the primary key Constraint. And there is a Foreign key linked to this table.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I fail to see how you've got this problem then because the unique constraint prevents duplicate data from being posted. The identity column is the primary key isn't it?
BTW - just a quick confidence test. You are using SQL Server aren't you?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
yes, it is the Primary key, i have not used the Unique Constraint, sorry about that. i thought if i make a Column Primary key and its identity. it will enforce the Uniqueness. my Field is a Primary key, and i have not defined the unique constraint.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Vuyiswamb wrote: yes, it is the Primary key, i have not used the Unique Constraint, sorry about that. i thought if i make a Column Primary key and its identity. it will enforce the Uniqueness. my Field is a Primary key, and i have not defined the unique constraint.
Surely if the field is the primary key, the database would not have allowed you to fill duplicate values in the first place?
And I also noticed that you said something like "looked identical" in your first post... how did you determine that you had duplicates in your table?
|
|
|
|
|
i have used a Query to Determine that.
SELECT *
FROM sde.Property p1
WHERE (FUNC_KEY = 'PV000000') AND EXISTS
(SELECT 1
FROM sde.Property p2
WHERE p2.lis_key = p1.lis_key
HAVING COUNT(p2.Property_ID) = 2)
order by Property_ID Asc
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
What happens if you just say
SELECT * FROM sde.Property WHERE (FUNC_KEY = 'PV000000')
how many records do you see?
|
|
|
|
|
i see Records with Dublicates in Property_ID.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Vuyiswamb wrote:
i see Records with Dublicates in Property_ID.
Then it looks like Property_ID is not the primary key of this table.
|
|
|
|
|
Either you must be referring to a Foreign Key Column for which Unique-Key Constraint is not set or You must be doing a Multi-Table Select . There is no chance of Identiy Primary key Column to generate Duplicate value.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
before deleting the record by below query
say
"delete from table1
where id='20'"
write set rowcount 1
it will delete only one if u had two identical row.
else if u have bulk records to be deleted
create temptable copy all distinct records to tahat table
truncate ur original table and copy the data from temptable ot original table
ex
step 1
create table #temptable
insert into #temptable
select distinct * from original table
step 2
truncate table original table
step 3
insert into #temptable
select * from #temptable x
hope it will work
Regards,
Suyash
|
|
|
|
|
hi. I want to export data from sqlserver to excel . but I want to do this with sql query , not enterprise manager.
is there any query to do this?
thanks.
|
|
|
|
|
Have a look at this article[^].
Paul Marfleet
|
|
|
|
|
i want to fetch the database schema(either MSACCESS OR SQLSERVER 2005).
language c#.
chanzeb chaudhary
|
|
|
|
|
You can get schema data from a DataAdapter object. For an Access DB, you can use System.Data.OleDb.OleDbDataAdapter. For SQL, System.Data.SqlClient.SqlDataAdapter. You use this object in conjunction with a connection object, a command object, and either a datatable or dataset. You can get the schema by using the .FillSchema function. Like this:
daMyDataAdapter.FillSchema(dsMyDataSet, SchemaType.Mapped)
You can search for more information in the articles and they can probably explain it better. Another way to get the schema is to setup a regular select statement but add 1=2 to the WHERE clause. Since 1 will never equal 2, it will bring back an empty dataset.
Hope this helps.
|
|
|
|
|
|
Hi.
In SQL Server 2005, when I attach a DB that is made in another computer, the primary key and Identity and diagram will be removed.
Oh! the diagram section don't open at all, so that I after attach must create another DB and imports tables in it, and then set primary key, Identity and make diagram!
Why?
Best wishes
|
|
|
|
|
I've just checked this.
Nothing like this happens. Do you save the changes in the diagram and tables after you make them?
|
|
|
|
|
Hi,
Is it possible to databind user.identity.name to formview text box that so user name is included when using insert New command. I want to include user name in sql table using formview without user having to input name?
Any help or appropriate link would be much appreciated.
Thanks
Steve
|
|
|
|