[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

Delete records on Firday only

Asked by zeeshanbutt in SQL Server 2005, Databases Miscellaneous

Tags: T-SQL, TSQL, tsql, SQL Server 2005, Stored Procedure, delete records, delete records on Friday only

Hi All,

I have a attached simple stored procedure which delete records from 3 tables. I want the stored procedure to delete records from 3 tables only when it is a Friday. And if it is not a Friday do not do anything (do not delete any records). How to Modify my stored procedure with this change?

Thanks in advance for the help.

Zee

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
--Start of Stored Procedure
 
Create PROCEDURE [dbo].[z_DeleteLastImportedProm] 
@DateFrom Datetime=NULL 
 
AS
BEGIN
 
SET NOCOUNT ON;
SET @DateFrom=CONVERT(VARCHAR(10),GETDATE()+2,120)
 
--Step 1
--Remove records from Table1 table
DELETE FROM Table1 
WHERE ProductStatus=1 and SimulationSID is NULL 
and StartDate>=CONVERT(VARCHAR(10),@DateFrom,120)
 
--Step 2
--Remove records from Table2 table
DELETE FROM Table2 
WHERE ProductStatus=1 and SimulationSID is NULL 
and StartDate>=CONVERT(VARCHAR(10),@DateFrom,120)
 
--Step 3
--Remove records from Table3 table
DELETE FROM Table3 
WHERE SimulationSID is NULL 
and StartDate>=CONVERT(VARCHAR(10),@DateFrom,120)
 
END
--End of Stored Procedure
[+][-]10/09/09 05:25 AM, ID: 25534226Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 05:27 AM, ID: 25534237Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 05:34 AM, ID: 25534291Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 05:34 AM, ID: 25534296Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/09/09 05:35 AM, ID: 25534298Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 05:36 AM, ID: 25534305Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 05:40 AM, ID: 25534334Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 06:13 AM, ID: 25534580Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/09/09 06:15 AM, ID: 25534592Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 06:17 AM, ID: 25534617Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/09/09 06:27 AM, ID: 25534703Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/09/09 09:14 AM, ID: 25536377Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 01:46 PM, ID: 25734154Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11/06/09 03:48 AM, ID: 25758303Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 04:16 AM, ID: 25758423Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625