473,461 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Deleting data from one table, where the date is older than a temp table

Hi,

I need to delete all data in a table where the date is older than that in a temp table.

Basically i have tblTrends and tbltempTrends. I only want new data in tblTrends as currently the data (imported weekly) into tbltempTrends just appends to tblTrends via a DTS package ran weekly.

Thanks!!
Nov 23 '10 #1
1 1262
NeoPa
32,556 Expert Mod 16PB
You probably need something like (you don't share field names so I'll guess) :
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM [tblTrends]
  2. FROM        [tblTrends] AS tT
  3.             INNER JOIN
  4.             [tblTempTrends] AS tTT
  5.   ON        (tT.TrendID = tTT.TrendID)
  6.  AND        (tT.Date < tTT.Date)
Your question also fails to say which records to even compare for dates, so I've assumed an ID field. Obviously you need to take the concept of the SQL and change it to match your own circumstances.
Nov 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: dev | last post by:
how create a temp table as a copy of a existing table and then update1 field and insert the hole temp table back in the existing table? please any help? if i have 10 fields in 1 record and...
2
by: Savas Ates | last post by:
i have a stored below it uses create temp table and drop temp table... when more than one user request the same page it probably returns error.. how can i solve this problem ...
2
by: Bill | last post by:
I have an entry form allowing customers to enter up to 15 skus (product id) at a time, so they can make a multiple order, instead of entering one sku, then submitting it, then returing to the form...
1
by: Jim | last post by:
For some reason the compiler is telling me that I must declarethe variable @costcenter_tmp on lines 74 and 98...but if i put a select statement in ther (for testing) before the loop I get data back...
5
by: Thanos | last post by:
hello, I've created a temp table within a stored pprocedure which was updated and changed. However I need to update an existing table with some column from the temp table. Below is my update...
0
by: gwaddell | last post by:
I have a stored procedure that is loading data into a global temp table. Here is all the code for that stored procedure. CREATE PROCEDURE AS SET NOCOUNT ON BEGIN
1
by: Timothy Perrigo | last post by:
(PostgreSQL 8.0 beta 4 on Mac OS X 10.3.6) I'm working on a function which creates and populates a temporary table, then returns the number of records it has inserted. I'm getting an error,...
16
by: pukivruki | last post by:
hi, I wish to create a temporary table who's name is dynamic based on the argument. ALTER PROCEDURE . @PID1 VARCHAR(50), @PID2 VARCHAR(50), @TICKET VARCHAR(20)
1
by: imani_technology_spam | last post by:
Right now, a client of mine has a T-SQL statement that does the following: 1) Create a temp table. 2) Populate temp table with data from one table using an INSERT statement. 3) Populate temp...
4
by: nerurmon | last post by:
Hai, I want to make a temp table in vs 2005. i have few field in one form and a datagridview. i want to make a temp table where i can store my different data in the controls(textbox, combo box) data...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.