Unable To Delete Records...SQL 2005

Mar 20, 2007

I've got an application I've written that should be able to (using a table) insert, update or delete records in SQL Server 2005. It can insert and update fine but it cannot delete any records. I'm totally stumped for how to figure out what's going on. I can remote on to the Windows 2003 Enterprise Server without any trouble so I should be able to read any log files or open the SQL Managemenent tools. How do I figure out what the issue is? It's a very strange thing and I'm stumped.

View 6 Replies


ADVERTISEMENT

Unable To Delete Duplicate Records

Jul 7, 2007

I was importing records via DTSWizard, and I was having problems so I turned off Enforce Replicaton, Enforce FK Constraints on a couple of fields. I'm new with SQL Server so I'm not sure if this even caused the problem. (Do I need to turn these back on, or is this a Developer switch of some kind?)



The end result left me with duplicate records in the table, and I'm not able to delete any of them. This is the Error I got...



A problem occurred attempting to delete row 1.
Error Source: Microsoft.VisualStudio,Datatools.
Error Message: The row value(s) updated or deleted either do not make the row unique or they after multiple rows(2 rows).



If someone could tell me what I need to do so I can delete the records I'd really appreciate it.



Thanks,

Bill

View 11 Replies View Related

Unable To Update Or Delete SQL Table Records

Jun 13, 2007

Hello,
I have been serching for weeks to resolve this problem.  I am new to ASP.NET and trying to make the migration from ASP which I have programmed in for years.  I am using Microsoft Visual Web Developer 2005 Express Edition and SQL Express Edtion.  I have been working through the Microsoft Video Training at http://msdn.microsoft.com/vstudio/express/beginner/learningpath/ and created a web site using Tier 3 Lesson 8 as the model.  My new web site which is a simple phone book applicaiton lets me read the table and select the record without any problem.  But the update form lets me edit but when I attempt to Apply the update I get the following error.
Server Error in '/Phonebook' Application.
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: FirstName, LastName, PhoneNumber, BossGroup, Department, BossPickup, ShowInPhonebook, Type, Original_FirstName, Original_LastName, Original_PhoneNumber, Original_BossGroup, Original_Department, Original_BossPickup, Original_ShowInPhoneBook, Original_Type, Original_ItemID.
Description: An unhundled expception occured during the execution of the current web request.  Please review the stack trace for more information about the error and where it originiated in the code.
The Stack Trace basiclly showes the same error as above.
Also, when I attempt to delete the record I do not get an error but the record does not delete.
What is interesting is that I can add a record so I do not believe that it is a security permissions issue.  I have the ISS Authinication Method Enable Anonymous Access set on with full control.
If anyone has any insight as to why this is occuring please let me know. 
 

View 13 Replies View Related

Unable To Delete Duplicate Records In Database

Jul 20, 2005

Hi,I have an sql database that has the primary key set to three fields,but has not been set as unique(I didn't create the table).I have 1 record that has 2 duplicates and I am unable to delete theduplicate entries.If I try to delete any of the three records(they are identical) I getthe message 'key column is insufficient or incorrect. Too many rowswere affected by update'.I am trying to do this within Enterprise Mgr.Any suggestion?Thanks much

View 2 Replies View Related

SQL 2005: Unable To Edit Linked Table Records

Oct 27, 2006

Hi!I am able to add records to my SQL 2005 database using bound forms in myAccess application, but if I try to edit any records (not only the newrecords I create) using the same bound forms, I receive a write conflict.For the record, I am currently the only user of this application and my SQLServer database has only one userID. I used this userID to create all ofthe objects in the database and to connect to the database from Access. Thedata sources for the bound forms are linked tables, the record source typeis set to "Dynaset" and the record locks are set to "No Locks". "Opendatabases using record-level locking" is checked.The write error says that another user has changed the current record sinceit was opened (since I'm currently the only user this isn't possible) andasks me to copy my changes to the clipboard or drop the changes.Can anyone suggest what might be causing this? Thanks!

View 1 Replies View Related

Master Data Services :: Hard Delete All Soft Delete Records (members) In Database

May 19, 2012

I am using Master Data Service for couple of months now. I can load, update, merge and soft delete data in MDS. Occasionally we even have to hard delete data from MDS. If we keep on soft deleting records in a MDS table eventually there will be huge number of soft deleted records. Is there an easy way to hard delete all the soft deleted records from all MDS tables in a specific Model.

View 18 Replies View Related

Data Flow Task To Delete Records And Then Insert Records In Transaction

Aug 6, 2007

HI,

I have been trying to solve the locking problem from past couple of days. Please help mee!!

Scenario:
--------------
I have a SSIS package in which 2 data flow tasks. 1st data flow task deletes records from a 5 tables and the 2nd data flow task should insert records into 1 of the five tables after the success of 1st data flow task. This scenario runs in Transacation.

The above scenrio in the 2nd data flow task hangs in runtime. It does not complete. with sp_who2 command i could see that there is an intent share lock(LK_M_IS) on the table and the status is SUSPENDED.

I dont know how to come out of this locking. Please help.

Thanks ,
Sunil

View 7 Replies View Related

Unable To Delete A Row In A Table

Jul 13, 2001

Is there any way to delete an unwanted row on a table with 300 or more constraints with less modifications to contraints? Or is there any other way that can remove the unwanted row without much risk? Dropping the constraints is possible but re-adding the constraints may not be possible because the create constraint statements are not known. And readding the constraints may take time because the database physical size is around 1GB... Please help

View 2 Replies View Related

Unable To Delete User

Aug 27, 2007

When trying to delete a user on SQL server 2000, we recieve the message "You cannot drop the selected login ID because that login ID owns objects in one or more databases."

We've tried a number of operations to find the objects owned by the user by searching for this error message in Google but, none of those suggestions work.

My questions are; Why does this happen, How can we avoid it in the future?

Our software applicaiton is case sensistive, and if a SQL security login is not created that matches the Domain login to the method used in the application - somehow we are suck. We can't create a new security for the login, nor can we delete or use the existing one.

View 1 Replies View Related

Unable To Delete A Replication Job In Sql Server

Aug 22, 2007

Hi,

I created and scheduled a test snapshot publication and a push subscription using the sql server replication wizard. Tested it and it worked all fine as the data was regularly replicated to the destination server correctly.

After I was satisfied with the test I deleted the replication and subscription without any problem. But I noticed that the jobs created by the replication wizard had not been deleted. I was disappointed as I had also expected these to be deleted because there are no more any local publication or replication on the server.

I, then, tried to delete the job by right click - and then delete. But I am unable to delete the pubilcation and subscription jobs at all. When I try to delete the sql server 2005 the following error message appears:

--start--------------------------------------------------------------------
"Attempt to retrieve data failed for object for server <MYSERVER>" (Microsoft.SqlServer.Smo
)
Addional Information

The job <jobname> does not exist on the server. (Microsoft.SqlServer.Smo)
--End--------------------------------------------------------------------

Can anyone help me on how to delete all replication jobs.

View 1 Replies View Related

Sa Is Unable To Delete User(urgent Pl. Help)

Dec 10, 2007

Please help, it's urgent!!
We are using sql server 2000 DB,
Sa is trying to delete a user from the Great Plains application and got the follow error:
Deleting the login failed for an unknown reason, contact your sql server administrator for assistance.

View 4 Replies View Related

Reporting Services :: Unable To Delete Reports

Apr 20, 2015

We have created and scheduled some test reports via Idera performance tool but we are unable to delete the reports. These are not custom reports and reports created with Schedule Email option in Idera. Unfortunately, I dera does not have any option to delete these reports and support is asking me if I tried this by deleting from SQL Server Reporting Services.I looked at the Reporting services but can't find any place to delete these reports. This link does not provide any support because I don't have these (Or Report Manager)----> Configuration Manager console, navigate to System Center Configuration Manager / Site Database / Computer Management / Reporting / Reporting Services.

URL....All I have is "Reporting Services Configuration Manager" under "Configuration Tools". How can I delete these reports from SQL Server Reporting services ?. Can I delete them from some tables in Reports databases ?. If so, what are the tables ?. I delete the jobs from SQL Server but the jobs are automatically created the next day emailing the reports again..

View 3 Replies View Related

-1.#IND Value In A Foat. Unable To Alter Or Delete Record

Mar 29, 2007

Somehow I got the value -1.#IND into several records in a table in SQL 2000 DB.

I assume that it is a kind of €œNot A Number€??

The problem I am facing now, is that I can not modify the value to a legal value. Nor can I delete the record that holds the number. I get the error message:

€œAnother user has modified the contents of this table or view, the database row you are modifying no longer exists in the database.
Database error: €˜[Microsoft][ODBS SQL Server Driver][SQL Server] A floating point exception occurred in the user process. Current transaction is cancelled.€?

Any suggestions or comments?

View 4 Replies View Related

Unable Delete Remote Files Using FTP Task

Sep 28, 2006

I can create remote folder and delete it

I also can create remote files but i can not delete remote files

error warning is like subject

any ides? thanks

View 7 Replies View Related

Unable To Delete Old ZIP Files Using Maintenance Plan

May 8, 2015

I'm using below script within the execute T-SQL statement task of the maintenance plan, which is created to delete the zip files older than 2 days, the task runs before the backup database task gets kicked off, but some how the task is not deleting the old .zip files.

Code being used within the task: output of the @delete_file variable within the delete command is Del X:SQLBackup*2015_05_06*.zip before it is passed to the final exec statement, the server is in EST time zone.

declare @ConvertDate char(10)
declare @Delete_file varchar(80)
set @ConvertDate = CONVERT ( char(10) , dateadd( dd, -2, getdate()) , 121 )

[code]....

View 5 Replies View Related

Unable To Update Or Delete GridView Entries... Must Declare The Scalar Variable @ID1.

Jan 22, 2007

Hello,
 I am having issues and can't see any errors in my code! When attempting to delete a table entry from my SQL database, I get the error "Must declare the scalar variable "@ID1"." even though I declare it as a parameter in my code! Can anyone see an issue with my code below?1 <asp:GridView ID="GridView1" runat="server" AllowSorting="True"
2 DataSourceID="SqlDataSource1" AutoGenerateColumns="False" OnSorted="GridView1_Sorted">
3 <Columns>
4 <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
5 <asp:BoundField DataField="column1" HeaderText="CO" SortExpression="column1" />
6 <asp:BoundField DataField="column2" HeaderText="Network" SortExpression="column2" />
7 <asp:BoundField DataField="column3" HeaderText="C/S/T" SortExpression="column3" />
8 <asp:BoundField DataField="column4" HeaderText="Date Received" SortExpression="column4" DataFormatString="{0:d}" HtmlEncode="False" />
9 <asp:BoundField DataField="DESCRIPTION" HeaderText="Description" SortExpression="DESCRIPTION" />
10 <asp:BoundField DataField="column5" HeaderText="In Service Date" SortExpression="column5" DataFormatString="{0:d}" HtmlEncode="False" />
11 <asp:BoundField DataField="REMARKS" HeaderText="Remarks" SortExpression="REMARKS" />
12 <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
13 SortExpression="ID" />
14 </Columns>
15 </asp:GridView>
16 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConduitConnectionString %>"
17 SelectCommand="SELECT [ID], [CO/Area] AS column1, [NW #] AS column2, [C/S/T] AS column3, [DATE REC'D] AS column4, [DESCRIPTION], [I/S DATE] AS column5, [REMARKS] FROM [Inspector Workload] WHERE ([Inspector Name] = @Inspector_Name) ORDER BY [CO/Area], [DATE REC'D]" DeleteCommand="DELETE FROM [Inspector Workload] WHERE (ID = @ID1)" UpdateCommand="UPDATE [Inspector Workload] SET [CO/Area] = @column1, [NW #] = @column2, [C/S/T] = @column3, [DATE REC'D] = @column4, [DESCRIPTION] = @DESCRIPTION, [I/S DATE] = @column5, [REMARKS] = @REMARKS WHERE ([ID] = @ID1)">
18 <SelectParameters>
19 <asp:QueryStringParameter Name="Inspector_Name" QueryStringField="Name" Type="String" />
20 </SelectParameters>
21 <DeleteParameters>
22 <asp:Parameter Name="ID" Type="Int32" />
23 </DeleteParameters>
24 <UpdateParameters>
25 <asp:Parameter Name="column1" Type="String" />
26 <asp:Parameter Name="column2" Type="Double" />
27 <asp:Parameter Name="column3" Type="String" />
28 <asp:Parameter Name="column4" Type="DateTime" />
29 <asp:Parameter Name="DESCRIPTION" Type="String" />
30 <asp:Parameter Name="column5" Type="DateTime" />
31 <asp:Parameter Name="REMARKS" Type="String" />
32 <asp:Parameter Name="ID" Type="Int32" />
33 </UpdateParameters>
34 </asp:SqlDataSource>
Thanks!Rob.

View 8 Replies View Related

Delete Records ?

Jan 31, 2007

Hello, its hard to explain, i have a table like this: --userpage_visitors-- id bigint owner nvarchar(20) visitor nvarchar(20) created datetime
Then i have some code like this:  (@Visitor is send to the stored proc)DECLARE @lastuser nvarchar(20)SELECT TOP 1 @lastuser = visitor FROM userpage_visitors WHERE (owner = @UserName) ORDER BY created DESCIF (@lastuser <> @Visitor)BEGININSERT INTO userpage_visitors (owner, visitor, created) VALUES (@UserName, @Visitor, @Created)-- delete hereEND
Now after i have inserted the new visitor into the table, i need to clean the table... so each user should have maximum of 30 visitors, so if the user i inserted above is the 31st user then i need to delete the first user, so i always have 30 fresch visitors,, if they have less then 30 visitors then nothing should happen. The question is, how can i get the 31th post? in mysql you can say that you want post 30, 31, but in mssql you only have the TOP to select limited posts, any ideas?
Patrick

View 1 Replies View Related

DELETE Records.

Mar 21, 2007

Hello, I have 3 tables with their columns as follows:   + LabelsInDocs [LabelId] PK FK , [DocsId] PK FK   + Labels [LabelId] PK , [LabelName]   + Docs [DocId] PK , [DocUrl] I set Cascade Delete On so when I delete a Doc all records in LabelsInDocs will be deleted. However, when a Doc is deleted I want also to delete all records in Labels for the labels which do not have any Doc associated to it in LabelsInDocs. How can I do this? Thanks, Miguel

View 1 Replies View Related

Delete Records ???

Jun 3, 2008

hello friends.
i have table1 in aspnetdb.mdf and i have picturefile of columname.. datatype of picturefile is vchar(50)
i want to delete my record automatically from my table1 after two weeks from inserting my record date..
i want to delete my picture file that located /pictures/tree.jpg (example).. pictures/tree.jpg was uploaded as picturefile on table1 by user before
how can i do this ?
cheers

View 5 Replies View Related

Pls Help!!! Delete Records In VB.net

Nov 29, 2003

Currently i writing a program to delete Records in the SQL database using VB.net language...
BUT i not sure whether i am right???
Pls provide me with the coding using a command object to delete records in SQL database...thank...however i tried the codes below but not working ...Pls help

Dim StrConnection As String = "workstation id=""ET-T15404-PC1"";integrated security=SSPI; etc

Dim objConnection As New SqlConnection(strConnection)
Dim strSQL As String = "Delete Seller.Admin FROMSeller WHERE Seller.no=tb.no"
Dim dbComm As New SqlCommand(strSQL, objConnection)

objConnection.Open()
dbComm.ExecuteNonQuery
objConnecion.Close()

View 1 Replies View Related

Delete Records

Jun 29, 2005

Hi.

there are 300 records on the table.
the table has a field of "ID (autonumber)"

How can I delete records without latest 20 records?

View 2 Replies View Related

Delete Records

Oct 9, 2006

There are 30 tables in my database and I need to delete all records within a date range. Could anyone help me?

View 4 Replies View Related

Delete Records

Sep 20, 2005

Hello,I have a database called articlesI want to delete all articles from a subgroup e.g. DVDIf I am in the enterprisemanager what steps do I have to take to do thisthanks in advancePaul

View 5 Replies View Related

Records Won't Delete

Jul 20, 2005

I have some records that will not delete, whenever I run a deletestatement in the Query analyzer, it never completes the statement, andI am only deleting one record at a time. Can anyone tell me why arecord wouldn't delete?

View 1 Replies View Related

Delete Records Every Day

Nov 8, 2006

Hi!

New on this

Is there a way on a sql sever where i can
delete som records one time every day
like if a field in my table is < getdate()

Alvin



View 6 Replies View Related

Unable To Show 0 To Many Records With Inner Join

May 2, 2008

I am having problem  with Inner joining of tables
 
my query is..
 Select j.jobSubject,e.eOrganization ,jv.JobClick,j.jobID from dbo.tbl_Jobs jinner join  dbo.tbl_Employer e on e.mId=j.jobCreatedByIDinner join dbo.tbl_JobView jv on jv.JobID=j.jobID
order by jv.JobClick desc This query returns 1 to many records
 
But I need the query should return  0 to many record . .yes I have already know inner join does not handle my problem so plz suggest me which type of join would solve my problem
 

View 3 Replies View Related

Unable To Get Records From Temp Table Using ASP

Nov 23, 2004

PLease help me with a intruiging problem with Stored Procedure, which is driving me mad.......

I wrote a Stored Procedure as listed below.
I've included the options
SET NOCOUNT ON
SET QUOTED_IDENTIFIER OFF

the results are stored in a #Temp table

The SP executes fine on Query Analyzer, and shows the contents of the temp table. BUt when I run this SP using ASP, I got the following error
-----------
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/test_site/test.asp, line 59
------------

I've tried using Recordset.MoveNextRecordset, if at all there are more than one recordset, obviously I got the same error







CREATE PROCEDURE atul_med.[sp_rep_sale2]
(
@rep_in varchar(100)

)
AS
SET NOCOUNT ON
SET QUOTED_IDENTIFIER OFF

DECLARE
@REP int,
@temp_pack varchar(20),
@temp_ntp int,
@temp_party_code varchar(20),
@temp_party_name varchar(20),
@temp_prod_code varchar(20),
@temp_prod_desc varchar(20),
@tot_qty int,
@tot_amount int,
@iCnt int,
@tot_sale_qty int,
@net_tot_sale_qty int,
@TableName varchar(10)

select @REP= @rep_in
set @tot_sale_qty=0
set @net_tot_sale_qty=0
set @TableName='#Test2'
--select @TableName='Test'
set @page=1
set @RecsPerPage=100

Declare @SQL VarChar(1000),
@cnt int,
@iCurLine int, @SQLX VarChar(1000)


set @iCurLine=1


set @iCurLine=1

select @Cnt = (SELECT count(*) FROM VW_PART_REP WHERE (REP = @REP))
print "Nos Of Party :"+ convert(char(1),@iCnt)

Create Table #Test2 (ID int identity,prod_desc nvarchar(100),pack nvarchar(100),ntp int)-- ,tot_qty int ,tot_amt int )




while @iCurLine <= @cnt
begin
SELECT @SQL= "ALTER TABLE #Test2 ADD "
SELECT @SQL = @SQL + "party_qty"+convert(char(2),@iCurLine)+" int "
set @iCurLine=@iCurLine+1
Exec (@SQL)
print @sql
end
SELECT @SQL= "ALTER TABLE #Test2 ADD "
SELECT @SQL = @SQL +"tot_qty int , tot_amt int "
SELECT @SQL = @SQL
exec (@SQL)
print @SQL



select * from #Test2

--Create Table #Test1 (ID int identity,prod_desc nvarchar(100),pack nvarchar(100),ntp int,party_qty1 int ,party_qty2 int ,party_qty3 int ,party_qty4 int ,party_qty5 int ,tot_qty int ,tot_amt int )
set @iCurLine=1


--=============================================



--print '=================Product Name========================'
DECLARE PROD_CUR CURSOR FOR
SELECT distinct(prod_code) as prod_code,prod_desc,pack,ntp FROM VW_sales_sum
WHERE (REP = @REP)
group by prod_code,prod_desc,pack,ntp

Declare @SQL_ins VarChar(1000)

OPEN PROD_CUR
FETCH NEXT FROM PROD_CUR
INTO @temp_prod_code,@temp_prod_desc,@temp_pack,@temp_n tp

WHILE @@FETCH_STATUS = 0
BEGIN


--Print @temp_prod_desc+'-'+convert(varchar(10),@temp_pack)+'-'+convert(varchar(10),@temp_ntp)
--print '=================prod_code :'+convert(varchar(10),@temp_prod_code)+'========= ==============='
print "============Insert Statement============"

SET @SQL_ins = "Insert into "+@TableName+" values("
SET @SQL_ins = @SQL_ins +""""+ @temp_prod_desc+""","""+@temp_pack+""","""+convert(char(10),@temp_ntp)+""","


DECLARE Party_CUR1 CURSOR FOR
SELECT party_code,party_name FROM VW_PART_REP
WHERE (REP = @REP) group by party_code,party_name

DECLARE @SQL1 varchar(10),@SQL2 varchar(100)
set @SQL2=''
OPEN Party_CUR1
FETCH NEXT FROM Party_CUR1
INTO @temp_party_code,@temp_party_name



WHILE @@FETCH_STATUS = 0
BEGIN
print "==Party_name :"+ @temp_party_name +"===Party_Code :"+convert(char(3),@temp_party_Code)
set @tot_sale_qty=0
set @tot_sale_qty= (select sum(issuedqty)as tot_qty from vw_sales_sum
where party_code =@temp_party_code
and (REP = @REP)
and (prod_code=@temp_prod_code))
if @tot_sale_qty IS NULL
begin
set @tot_sale_qty=0
print "===Tot Qty :"+convert(varchar(10),@tot_sale_qty)
end
else
begin
print "===Tot Qty :"+convert(varchar(10),@tot_sale_qty)
end
SELECT @SQL1 = @tot_sale_qty
select@net_tot_sale_qty=@net_tot_sale_qty+@tot_sale_qty
--print @SQL1
Select @SQL2 = @SQL2 + @SQL1 +","



FETCH NEXT FROM Party_CUR1
INTO @temp_party_code,@temp_party_name

END

CLOSE Party_CUR1
DEALLOCATE Party_CUR1
print '==============================='
print @SQL2+convert(char(4),@net_tot_sale_qty)


--set @net_tot_sale_qty=@tot_sale_qty+@net_tot_sale_qty
--SET @SQL = @SQL+convert(char(10),@tot_sale_qty)+','
--set @tot_sale_qty=0

Select @SQL_ins = @SQL_ins+@SQL2+convert(char(8),@net_tot_sale_qty)
Select @SQL_ins = @SQL_ins+","
Select @SQL_ins = @SQL_ins+convert(char(12),(@net_tot_sale_qty*@temp _ntp))
Select @SQL_ins = @SQL_ins+")"
print @SQL_ins
Exec (@SQL_ins)

select@net_tot_sale_qty=0
FETCH NEXT FROM PROD_CUR
INTO @temp_prod_code,@temp_prod_desc,@temp_pack,@temp_n tp


END


CLOSE PROD_CUR

DEALLOCATE PROD_CUR



SELECT * FROM #Test2


SET NOCOUNT OFF
GO
SET QUOTED_IDENTIFIER ON
GO

View 8 Replies View Related

Delete All Records From A Database

Aug 30, 2007

Is there a way to delete all records in a SQL Server 2005 database? A function or a script?

View 8 Replies View Related

How Do I Delete One Of A Pair Of Records.

Sep 8, 2007

I have a table, gdbdoc,  that contains record-key pairs, linking records in another table.   There is no significance in the order of the link: if records A and B are linked, then I don't care whether the link is A -> B or B -> A, and my normal query logic is     SELECT ... Where DCIindiid = A ...     union     SELECT ... Where DCILinkid = A(DCIindiid = key1, DCILinkid = Key2)
The link-creation process normally checks whether there is already a link in either direction.  Thus before creating a link A->B the logic checks to see whether either the A->B or B->A link record exists, and a new link is not created if the link already exists in either direction.  However recently one of my processes bypassed the reverse-link check, and I've ended up with a few hundred cases where there is both an A->B link and a B->A link. 
If I run a query: -      select gd1.* from gdbdoc as gd1 join gdbdoc as gd2 on gd1.dciindiid = gd2.dcilinkid and gd1.dcilinkid = gd2.dciindiid
this displays all the records where one record links A -> B and there is also another record that links B -> A. 
How do I write a query to delete ONE of the pair of duplicate records?  I have two problems: -
Problem 1:  Table gdbdoc is keyed on (DCIindiid, DCILinkid).  Both guids are needed to create a unique key, and the table does not have a single key field.  You can't write    DELETE gdbdoc where DCIIndiid, DCILinkid IN select gd1.dciindiid, gd1.linkid                             from gdbdoc as gd1 join gdbdoc as gd2 on gd1.dciindiid = gd2.dcilinkid and gd1.dcilinkid = gd2.dciindiid
as the DELETE ... SELECT ... syntax only seems to support a single returned value.  
Problem 2.  If we solved problem 1, we would (I think) delete BOTH the A->B link and the B->A link , whereas I only want to delete one of these links.
Afterthought:  Problem 2 seems easily solvable:  add "Where gd1.DCIindiid < gd1.DCILinkid" to the DELETE ... statement.  Although the concept of "<" doesn't really mean anything with a guid, this is accepted by SQL, and halves the number of records returned by the select.  Obviously I don't care which of the two links (A->B or B->A) is deleted.
Regards, Robert Barnes

View 3 Replies View Related

Delete Duplicate Records

Jul 30, 2004

I use a tabel for storin log data from a mail server. I noticed that I'm getting duplicate records, is there a way to delete the socond and/or third entry so I dont have any duplicates?

I need this done in SP.

View 1 Replies View Related

How To Delete Records That Are Greater Than 1 Day?

Jun 1, 2000

Hello,

I would like to create a job that runs ones a day to delete records in a table that are older than one day. Any ideas?

Thanks,
Nina Melhem

View 2 Replies View Related

Delete Duplicate Records

Oct 19, 2000

Sorry for the new thread.

I have a userprofile table. There are a lot of duplicate records in this table. e.g.

USERID-----LASTNAME---EMAILADDRESS----CREATEDATE
----------------------------------------------------------------------
1----------A-----------A@yahoo.com---------2000-09-05 16:07:00.000
2----------A-----------A@yahoo.com---------2000-09-10 16:07:00.000
3----------A-----------A@yahoo.com---------2000-09-15 16:07:00.000

Userid is auto number, lastname and emailaddress are PK.

I want to delete duplicate records. If lastname and emailaddress are the same, only keep a record which createdate is the most newest date. See above example I only want to the record which userid is 3. I have alreday created a code which I attached below. This code onle keep a record which userid is 1.

Anybody can help me to solve this problem? Thanks.

============== My current code ====================
delete from userprofile where userprofile.userid in
--list all rows that have duplicates
(select p.userid
from userprofile as p
where exists
(select lastname, emailaddress
from userprofile
where lastname = p.lastname and emailaddress = p.emailaddress
group by lastname, emailaddress
having count (userid)>1))
and userprofile.userid not in
--list on row from each set of duplicate
(select min(p.userid)
from userprofile as p
where exists
(select lastname, emailaddress
from userprofile
where lastname = p.lastname and emailaddress = p.emailaddress
group by lastname, emailaddress
having count (userid)>1)
group by lastname, emailaddress)

View 2 Replies View Related

How To Delete The Records In The Table

Jul 20, 2005

:confused: Urgent!!
Hi there. I use MS SQL server. I would like to separate the data from one table to two tables refer to two reference tables and the following conditions:

Let say these two reference tables are called:
Table A & Table B

Group A:
1. Same date in Table A & Table B
2. Same ID in Table A & Table B (ID is not unique)
3. Same name in Table A & Table B (Name is not unique)

Combine all of these three conditions for unique identifier.

I used the following SQL code to separate the required data that match the above conditions to the new table.
(Code)
select a.Project, a.Site, a.S_number, a.Field_ID, a.Method, a.Analyte, a.Result, a.Units,
a.Qualifier, a.Dilution_Factor, a.Reporting_limit, a.Recovery_, a.Matrix, a.CAS_Number, a.Sample_Date,
a.Received_Date, a.Prep_Date, a.Analysis_Date, a.Batch_ID, a.Data_Package_num_SDG, a.Lab_Sample_ID,
a.Lab into APPL_union_exist from APPL_union_update a, Before_01012004_report b
where a.Field_ID = b.[Field Sample] and a.Sample_Date = b.Collected and a.Analyte = b.Analyte


However, I don't know how to delete the data that copied to the new table in original table, or separate that to the new table. Wish someone can help me. Thanks a lot

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved