Deleting Data From Database

Nov 23, 2004

Edited by SomeNewKid. Please post code between <code> and </code> tags.








I have added a delete button to my datagrid, and put in what I think is the code to delete a member from the database at their Member ID, however when I have called a members details and the delete button is pressed, nothing happens!!??


Any ideas?


Here is the code:





<%@ Page Language="VB" %>


<script runat="server">





' Insert page code here


'


Function GetMember(ByVal iD As Integer) As System.Data.SqlClient.SqlDataReader


Dim connectionString As String = "server='localhost'; trusted_connection=true; Database='adp1SQL'"


Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)





Dim queryString As String = "SELECT [oga].* FROM [oga] WHERE ([oga].[ID] = @ID)"


Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)





sqlCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = iD





sqlConnection.Open


Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)





Return dataReader


End Function





Sub dgMember_Delete(sender as Object, e as DataGridCommandEventArgs)


dgMember.EditItemIndex = -1





dgMember.DataSource = GetMember(memberID.Text)


dgMember.DataBind()





End Sub








Sub btnView_Click(sender As Object, e As EventArgs)


dgMember.DataSource = GetMember(memberID.Text)


dgMember.DataBind()


End Sub





Sub dgMember_SelectedIndexChanged(sender As Object, e As EventArgs)





End Sub


Function DeleteMember(ByVal iD As Integer) As Integer


Dim connectionString As String = "server='localhost'; trusted_connection=true; Database='adp1SQL'"


Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)





Dim queryString As String = "DELETE FROM [oga] WHERE ([oga].[ID] = @ID)"


Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)





sqlCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = iD





Dim rowsAffected As Integer = 0


sqlConnection.Open


Try


rowsAffected = sqlCommand.ExecuteNonQuery


Finally


sqlConnection.Close


End Try





Return rowsAffected


End Function





</script>


<html>


<head>


</head>


<body id="dgMemberInfo">


<font face="arial">


<h1><img src="thlogotop.gif" align="left" /> <img src="thlogotop.gif" align="right" />


<br />


<center><font color="red">T</font>albot <font color="red">H</font>eath <font color="red">O</font>ld <font color="red">G</font>irls <font color="red">A</font>ssociation


</center>


</h1>


<h2 align="center">Delete a Member


</h2>


<asp:HyperLink id="HyperLink1" runat="server" Width="94px" NavigateUrl="Default.aspx">Main Menu</asp:HyperLink>


<hr />


<br />


<br />


<br />


<p align="center">


</p>


<form runat="server">


<br />


<div align="center">Please Enter Member ID :


<asp:TextBox id="memberID" runat="server"></asp:TextBox>


</div>


<br />


<br />


<br />


<br />


<div align="center">


<asp:Button id="btnView" onclick="btnView_Click" runat="server" Width="204px" Text="View Member Details"></asp:Button>


</div>


<br />


<br />


<p align="center">


<asp:DataGrid id="dgMember" runat="server" BorderColor="Black" OnSelectedIndexChanged="dgMember_SelectedIndexChanged" AutoGenerateColumns="False" OnDeleteCommand="dgMember_Delete">


<Columns>


<asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"></asp:ButtonColumn>


<asp:BoundColumn DataField="ID" HeaderText="ID">


<HeaderStyle font-bold="True" horizontalalign="Center" verticalalign="Middle"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Member No" HeaderText="Member No">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Surname" HeaderText="Surname">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Forenames" HeaderText="Forenames">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Known as" HeaderText="Known As">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Title" HeaderText="Title">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Address" HeaderText="Address">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Home Tel" HeaderText="Home Tel">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="Email" HeaderText="Email">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="DOB" HeaderText="DOB">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="StartDate" HeaderText="StartDate">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="LeaveDate" HeaderText="LeaveDate">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


<asp:BoundColumn DataField="clubsoc" HeaderText="Club/Society">


<HeaderStyle font-bold="True" horizontalalign="Center"></HeaderStyle>


</asp:BoundColumn>


</Columns>


</asp:DataGrid>


</p>


<p align="center">


</p>


<p align="left">


<br />


<br />


&nbsp;


</p>


<!-- Insert content here -->


</form>


</font>


</body>


</html>

View 2 Replies


ADVERTISEMENT

Data Mining :: Deleting Old Data From Adventure Works 2012 With Powershell

May 3, 2015

I am trying to delete tables from data where the ModifiedDates older than 9 years in AdventureWorks2012 database . I get console notified that foreign keys are dropped but the delete statement is throwing errors. I am sure that somewhere the key constraints are not getting altered, but i'm not able to figure it out as i'm a relative beginner to T-SQL. The error and code:

The DELETE statement conflicted with the REFERENCE constraint "FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID". The conflict
occurred in database "AdventureWorks2012", table "Sales.SalesOrderHeader
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
$option_drop = new-object Microsoft.SqlServer.Management.Smo.ScriptingOptions;
$option_drop.ScriptDrops = $true;

[Code] ....

View 3 Replies View Related

Power Pivot :: Deleting Data Content From Data Model

Sep 10, 2013

I don't know if the question has been nailed down.  Aside from deleting tables, can we delete the *content* of data within the tables.  It doesn't seem crazy that, if you can pull in data from a feed then you should be able to remove the content out again (without also destroying the user's meta-data work ).  Reasons for this include:

- Security (a user may not have rights to see *my* data and should go refresh their own)
- Size (workbook doesn't need to have GB's of irrelevant data saved to disk in a workbook if it was just useful during development phase to a pre-production data feed)
- Bad data (pre-production data feed is not good data)
- User-friendliness (data feed was refreshed 2 years ago and workbook was saved to file server.  Users shouldn't be presented with irrelevant data, but should get empty pivot tables until they go do their refresh)

Obviously Excel internally knows how to clear out PowerPivot data, given the prompt shown here: [URL] ....

But how does a user initiate this on their own (corruption aside)?

Previous time this question was asked, without a real resolution: [URL] ....

View 8 Replies View Related

Archive Data Instead Of Deleting It To Prevent 4GB Data Limit

Mar 14, 2008

We are running SQL Server 2005 express on Windows 2003. The database server gets significant amounts of data.



Because of the 4GB data limit we have a daily cron task which goes through and deletes data older then 90 days.



We would like a way to archive this data instead of deleting it. Is there any way to take data and compress it and store it in a different way, so that if needed, customers can query directly out from the compressed data? Cleary querying from compressed would be slower but that is ok.



Any other solutions that would allow us to archive data instead of deleting it? Thanks.

View 10 Replies View Related

Deleting Existing Data Before Loading New Data

Apr 10, 2007

I have a package which loads data from a flat file (csv) to 4 tables in a database.
Now, the load is incremental.

I want to clear the data of all 4 tables(in the database) before loading the data from flat file everytime.How can i do this?
Iam using 4 Oledb Destinations, 1 multicast, 1 source component to do this.
Also can it happen like a transaction? because if it deletes the existing data and couldnt load new data there will be a problem!.how to avoid this?

View 4 Replies View Related

Deleting The Master Table Withour Deleting The Child Tables

Aug 9, 2007

Hi
i have to delete the master table data without deleting the child table records,is there any solution for this,  parent table has relation with the child table.
regards
vinod.t.v

View 9 Replies View Related

Deleting Data From DB

Nov 23, 2006

I have edited the aspnet_Users_CreateUser stored procedure so that the UserId that is created when a new user is created is copied to a UserId field in another table. However, when I use the website administration tool to delete users that have been created, it gives me an error saying the delete statement conflicted with the reference constraint. I then added the following code in the aspnet_Users_DeleteUser procedure....
IF ((@TablesToDeleteFrom & 16) <> 0 AND
(EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_tt') AND (type = 'V'))))
BEGIN
DELETE FROM dbo.userclassset WHERE @UserId = UserId
SELECT @ErrorCode = @@ERROR,
@RowCount = @@ROWCOUNT
IF( @ErrorCode <> 0 )
GOTO Cleanup
IF (@RowCount <> 0)
SELECT @NumTablesDeletedFrom = @NumTablesDeletedFrom + 1    hdhd
END
This code was then added to the function at the end which deletes the data from the aspnet_Users table when everything else has been removed
(@TablesToDeleteFrom & 16) <> 0 AND
Now when I delete a user in the website admin tool, it "deletes" (with no error) the user from the list but doesnt actually physically delete it from the database.
Any ideas?
 

View 1 Replies View Related

Deleting All Data

Jul 26, 2007

Is there a way to delete all data from a database - all tables and alltables excluding system tables?sqlserver 2000?Thanks,Tmuld

View 3 Replies View Related

T-SQL (SS2K8) :: Deleting Only 1 Row At A Time Instead Of Using Condition And Deleting Many Rows?

Jul 18, 2014

/****** Object: StoredProcedure [dbo].[dbo.ServiceLog] Script Date: 07/18/2014 14:30:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[ServiceLogPurge]

-- Purge records dbo.ServiceLog older than 3 months:
-- Purge records in small portions to avoid locking production tables
-- for a long time. The process takes longer, but can co-exist with
-- normal usage of the tables.

[Code] ...

*** Getting this error below when executing the code ***

Msg 102, Level 15, State 1, Procedure ServiceLogPurge, Line 45
Incorrect syntax near 'Failed:'.

View 9 Replies View Related

Deleting Items In My Database

Mar 24, 2008

hi I Cant delete items in my grid view.. here is my code




















"
DeleteCommand="DELETE FROM [aspnet_Membership] WHERE [UserId = @UserId]" SelectCommand="SELECT First, Last, Email, CreateDate, IsApproved, IsLockedOut FROM aspnet_Membership">






when i run it.. and clicked the delete button.. this appears:

Server Error in '/mapuaResearch' Application.
--------------------------------------------------------------------------------

An expression of non-boolean type specified in a context where a condition is expected, near 'UserId = @UserId'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An expression of non-boolean type specified in a context where a condition is expected, near 'UserId = @UserId'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SqlException (0x80131904): An expression of non-boolean type specified in a context where a condition is expected, near 'UserId = @UserId'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +95
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3430
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +186
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1139
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +407
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +149
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +493
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +922
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +176
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +914
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1067
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +215
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +244
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3839




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832


PLEASE HELP ME!!!!! TNX

View 2 Replies View Related

Cannot Reuse Database Name After Deleting Old One

Apr 19, 2008



Hi. I'm starting to try out LINQ to SQL, and so I'm using SQL Express (on Vista) to experiment. My problem is that once I create and delete a database, I can never use the name again. If, after deleting the old database, I try to create another one with the same name (say Acct1), I get "Create failed for Database 'Acct1'. An exception occurred while executing a Transact-SQL statement or batch. The logical file name "Acct1" is already in use. Choose a different name. Error: 1828"

I am trying to create the database in SQL Server Management Studio Express. That database name does not appear in the list of databases: there is only AdventureWorks and the system databases. The .MDF and .LDF files have been deleted. Not just sent to the recycle bin, but permanently deleted.


I have already used up Acct1, Acct2, and Acct3, just to try out different scenarios. Each time, I delete the old database before trying to create a new one with the same name, but I am forced to always supply a new, different name. I have checked the directory with hidden files and system files showing to be sure there is no old file lurking there somewhere.


Is there a way to delete these old "logical file names"? I can't even find any reference to their existence except for the message that says they are already in use.

View 11 Replies View Related

Deleting A Database Engine

Mar 14, 2008

I have recently installed SQL server 2005 express edition along with Sql server management studio expressI have run the installation twice and during the installation I have created two instances of SQL server one named instance having Windows authentication and the other default instance having mixed mode authentication. Now I want to delete the named instance. Could anybody tellme I can delete the named instance?

View 3 Replies View Related

I Have A Problem For Deleting Data

Oct 23, 2007



my row in my data base consists of 12 coulmns, i have a duplicate values in 6 coulmns of it , i use select distinct for all it doesnt work for it it doesnot remove dupliacte , i cant make primary key or any constraint on this 6 coulmns together cause it contains duplicate values even if i choose ignore duplicate it doesnot work

example
id name adress telephone job gender deprtment
1 john dd 123 doctor m 1st deprtment
1 john dd 123 doctor m 2nd deprtment

so there is duplicate on id, name,telephone, job , gender and different in department so how i make a primary key on id , name , adress , telephone , job , gender together

also how to delete duplicate from it although i used distinct function and it doesnit remove duplicate

thanks in advance

View 3 Replies View Related

Deleting Data After Replication.

Aug 8, 2007

I am looking for an opinion on the best way to delete all data from a table after it has been replicated.

The simple use case would be:



Data is replicated from production server to archive server.
Data is deleted from production serverThanks in advance...

View 6 Replies View Related

Deleting Old Unused Database Issue

Nov 7, 2007

I have an old DATABASE that is not more in use , so I want to drop that database.
But before that I want to check that is there any application running on it or not.

can any one suggest me how to do this?

thanks

View 5 Replies View Related

Deleting 8 Million Rows From Database

Jul 16, 2013

i am deleating 8 Million rows from my database,I am wondering how to control T-Log,also I heard something about row lock and table lock

View 4 Replies View Related

Deleting Empty Tables In Sql Database??

Apr 2, 2006

Hello I have 16000 tables in a sql database and I need a sql query command to delete empty tables from that sql database please help.

F16 LÃ?GHTÃ?NÃ?NNNG

View 8 Replies View Related

Problems Deleting Row In SQL Express Database

Mar 6, 2008



I have been trying to develop a simple delete operation in VB using a local SQL Express database located inside the project. My selects, inserts, and updates are working ok, but for some reason my delete doesn't want to work.

I have the database file set to "copy if newer" in the properties and am only using a simple parameterized query to delete. I am not using an bound controls like datagrid and even when I do, the same problem occurs. I am also not using a dataset object.

I have setup a SqlConnection object and a SqlCommand object in my code. The command is set to the Sql text of




Code Snippet
DELETE FROM Providers
WHERE (PaymentDate BETWEEN @StartingDate AND @EndingDate)




In my Database, I have a field called ID which is the primary key and is set as an identity field. PaymentDate is a datetime value and the two parameters "@StartingDate and @EndingDate" are also datetime values passing only the date value from a datetimepicker control in VB.




Code Snippet

SqlCommand1.Parameters("@StartingDate").Value = CType(dateTimePicker1.Text, Date)
. . .
sqlCommand1.ExecuteNonQuery()




and so on.

Anyway, when I run the code, and even when I pass a return value back, it shows it deleted the record without any errors. However, I normally have a query window open selecting all records and before closing the program, I refresh this query and no changes have occurred. The record I tried to delete is still there.

I have tried several time and using several different method (Stored Procedures, databound controls, ete) and am getting the same result each time.

In asking this question in the MSDN VB Forums since I figured it was more than likely a VB problem and not a SQL issue, I was eventually directed here.

For details on the other posting, please see: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2933961&SiteID=1

Thanks in advanced for the help.

Nate (aka Socnorb)

View 6 Replies View Related

Trouble Deleting Data In Table

Mar 9, 2007

I have a table where I want to delete some data from but I get this error.

You might have a record that has a foreign key value related to it, or you might have violated a check constraint.

What to do????

View 1 Replies View Related

SQL Db Size Will Not Decrease After Deleting Data

Jun 6, 2004

Hi

I installed " Web Wiz Forum ASP SQL 2000 DB "

it work fine but
when i added some data in the forum for example my db size is 1.45 MB

after i delete those data the db size will not decrease

is there any code that i must enter on the sql server setup file

Excuse me i asked this question in the web wix forum site but they don`t
answer me

if know what i must to do plz tell me


Thanks

View 6 Replies View Related

SQL 2012 :: SP For Deleting All Data From A Table

Mar 13, 2014

Is this close to the correct syntax for a stored procedure for deleting all the data from a particular table... or is there a better way?

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE TruncateTmpBank

[Code] ....

View 3 Replies View Related

Archiving And Deleting Records (Data)?

Aug 10, 2015

I wrote a script to archive and delete records rom a table back in 2005 and 2009.

I can't seem to get the syntax right. Any sample script to simply archive and delete records?

This is what I have so far.

DECLARE @ArchiveDate Datetime
SET @ArchiveDate = (SELECT TOP 1 DATEPART(yyyy,Call_Date)
FROM tblCall
ORDER BY Call_Date)
--SELECT @ArchiveDate AS ArchiveDate
DECLARE @Active bit

[Code] ....

View 9 Replies View Related

Deleting Massive Data From A Table

Jan 20, 2014

I have to delete a ton of data from a SQL table. I have a unique identifier called the version. I would like to use if not in these versions then delete. I tried to using the statement below, but learned the hard way that it created an error this is the message I got....

Msg 9002, Level 17, State 4, Line 3...

The transaction log for database 'MonthEnds' is full due to 'ACTIVE_TRANSACTION'.

I was reading about truncate, I am not sure how I would do this or how I would setup the statement.

Delete Products
where versions were not in (('48459CED-871F-4971-B888-5083990332BC','D550C8D3-58C7-4C74-841D-1C1675F19AE3','C77C7817-3F04-4145-98D3-37BB1610DB35',
'21FE83FA-476D-4604-80EF-2ED57DEE2C16','F3B50B81-191A-4D71-A406-011127AEFBE1','EFBD48E7-E30F-4047-909E-F14DCAEA4181','BD9CCC41-D696-406B-
'C8BEBFBC-D362-4D0F-A555-B281FC2B3023','EFA64956-C2CF-41FC-8E21-F060597DAFCB','77A8DE56-6F7F-4490-8BED-AA6809B947EF','0F4C1E5F-B689-4DCB-

[code]....

View 2 Replies View Related

Deleting Orphaned Data - Maintenance

Dec 10, 2007

Hi,

I really don't know how frowned upon my approach is here, but it was the only way I have been able I've been able to do it.

On my application, when users delete their account, it sometimes brings the db server to a COMPLETE crawl. The reason is some users who delete have many years of related data, and when the data deletes with them, its very slow.

To avoid this I've taken off many contstraints, and I do have some sprocs that deleted orphaned data at night.

thoughts on this approach ?

View 5 Replies View Related

Data From The Table Deleting Automaticaly.

Feb 13, 2008

Hi gurus,

The data is automaticaly deleting from one perticular table at every night from last week onwords. I have created a delete trigger to find it out. But Nothing was recorded. There is no jobs except maintainance plans. Nothing in event viewer too. The database recovery model is simple. How can i solve this problem
Please advise me to solve this problem

Thanks
Krishna.

View 11 Replies View Related

Deleting Data By Comparing To Another Table

Jul 20, 2005

I have an entry form allowing customers to enter up to 15 skus (productid) at a time, so they can make a multiple order, instead of enteringone sku, then submitting it, then returing to the form to submit thesecond one, and so forth.From time to time, the sku they enter will be wrong, or discontiued, soit will not submit an order.Therefore, when they are done submitting their 15 skus through the orderform, I want a list showing them all of those skus that came back blank,or were not found in the database.I'm doing this by creating two tables. A shopping cart, which holds allthe skus that were returned, and a holding table, that holds all theskus that were submitted. I want to then delete all the skus in theholding page that match the skus in teh cart (because they are goodskus) which will then leave the unmatched skus in the holding table.I'll then scroll out the contents of the holding table, to show them theskus that were not found in the database.(confused yet?)So what I want to do is have some sql that will delete from the holdingtable where the sku = the sku in the cart. I've tried writing this, butit dosn't work.I tiried this delete from holding_table where sku = cart.skuI was hoping this would work, but it dosn't. Is there a way for me to dothis?Thanks!Bill*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 2 Replies View Related

Deleting Data From Primary Table

Mar 20, 2008



Hi Everybody,

Kindly let me know if there is a way of deleting data from primary table without deleting data from its corresponding foreign key table.

Thanks & Regards

View 2 Replies View Related

Problem Deleting Duplicate Data

Sep 27, 2006

I have a table that contains more than 10,000 rows of
duplicate data. The script below copies the data to a temp table then
deletes from the original table. My problem is that after it runs, I now
have 122 rows of triplicate data (but dups are gone). If I rerun the script, it doesn't see the
triplicate data and returns 0 rows. I've use three different versions of
delete dup row scripts with the same result. There are no triggers or
constraints on the table, not even a primary key. What am I missing?-------------------------------------------------------------------

/**********************************************
Delete Duplicate Data
**********************************************/

--Create temp table to hold duplicate data
CREATE TABLE #tempduplicatedata
(
[student_test_uniq] [bigint] NULL,
[test_uniq] [int] NULL,
[concept_id] [smallint] NULL,
[test_id] [varchar](12) NULL,
[questions_correct] [smallint] NULL,
[questions_count] [smallint] NULL,
[percentage_correct] [decimal](6, 3) NULL,
[concept_response_count] [smallint] NULL
)

--Identify and save dup data into temp table
INSERT INTO #tempduplicatedata
SELECT * FROM crt_concept_score
GROUP BY student_test_uniq,
test_uniq,
concept_id,
test_id,
questions_correct,
questions_count,
percentage_correct,
concept_response_count
HAVING COUNT(*) > 1

--Confirm number of dup rows
SELECT @@ROWCOUNT AS 'Number of Duplicate Rows'

--Delete dup from original table
DELETE FROM crt_concept_score
FROM crt_concept_score
INNER JOIN #tempduplicatedata
ON crt_concept_score.student_test_uniq = #tempduplicatedata.student_test_uniq
AND crt_concept_score.test_uniq = #tempduplicatedata.test_uniq
AND crt_concept_score.concept_id = #tempduplicatedata.concept_id
AND crt_concept_score.test_id = #tempduplicatedata.test_id
AND crt_concept_score.questions_correct = #tempduplicatedata.questions_correct
AND crt_concept_score.questions_count = #tempduplicatedata.questions_count
AND crt_concept_score.percentage_correct = #tempduplicatedata.percentage_correct
AND crt_concept_score.concept_response_count = #tempduplicatedata.concept_response_count

--Insert the delete data back
INSERT INTO crt_concept_score
SELECT * FROM #tempduplicatedata

--Check for dup data.
SELECT * FROM crt_concept_score
GROUP BY student_test_uniq,
test_uniq,
concept_id,
test_id,
questions_correct,
questions_count,
percentage_correct,
concept_response_count
HAVING COUNT(*) > 1

--Check table
-- SELECT * FROM crt_concept_score

--Drop temp table
DROP TABLE #tempduplicatedata
GO

View 1 Replies View Related

Deleting Data Using Table Prefix

May 30, 2006



I can run a select to retrieve data using a prefix 'a' for the specific table involved. However when I try to run a delete using the same criteria it fails telling me

Msg 102, Level 15, State 1,.......Line 1

Incorrect syntax near 'a'



The Select statement looks like:

select count(*) from schema.table a where a.customer_id=1234

The Delete looks like:

delete from schema.table a where a.customer_id=1234

What am I doing wrong here? and how can I prefix the table, because the command I want to run is much more complicated than the example above and it needs the prefix

View 3 Replies View Related

Deleting Data Bloats Log File

Aug 22, 2007

When I delete substantial amounts of data using the SQL DELETE command, the database size apparently remains the same (702 mb) and the log file goes from about 17 mb to over 1 gig. I was expecting for the overall size to decrease drastically, but got just the opposite.

Is this typical? Can I do something to slim it down? As I am just trying to decrease the overall size to make it easier to work with when creating my application in VB, I am not worried about restoring the db (I have secure copies).

View 15 Replies View Related

Deleting Data From Production Sever

Jan 9, 2008



Hi All,
I have to delete 135 Million records from our production server, keeping only last three months data & the table doesnot have any index.

Can you please suggest the best possible approach to perform this activity.

Approach i am thinking :-


1)I will rename the existing table & create a new table with the same name (By this my application wont be interrupted)
2)then i am planning to create a nonclustered index on the date column sort order desc so that i can get the last three months data.
3)Once the index is created i can transfer the required records to the new table created in step 1.

Please sugeest your valuable feedback or suggestions to perform the task ASAP.

Thanks


View 9 Replies View Related

Deleting Records From A Table In Server Database

Aug 24, 2015

I'm trying to delete some records from some tables in a SQL Server 2008 R2 database. There's a foreign key relationship between the two tables. To make things easier here's the definition of both tables:

-- Parent table
CREATE TABLE [dbo].[PharmInvInItemPackages](
[InventoryInDetailID] [int] IDENTITY(1,1) NOT NULL,
[InventoryInID] [int] NOT NULL,
[ItemPackageID] [int] NOT NULL,

[code]....

View 5 Replies View Related

Stored Procedures For Inserting And Deleting Data

May 2, 2007

Hi, am new to sql server. Please some one send me some introduction abt stored procedures and some coding exammples to update and fetch the data from datasourece.
thanks.

View 2 Replies View Related







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