|
[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. |
|
|
|
|
Asked by zeeshanbutt in SQL Server 2005, Databases Miscellaneous
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
|
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625