Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing Tables.

Status
Not open for further replies.

Work23

Technical User
Mar 8, 2005
94
US
Hello. If I want to Clear a table created in my database by SQL written by me, how would I do so? I need the table to clear everytime the program is run so it is updated with the most current data. This is the code that currently Inserts the data into the table. What would I need to add to this code to clear the table of its data when the code is ran the next time?




INSERT INTO DBO.MYTABLE

SELECT
E.HSE_ID,
E.HSE_TIMESTAMP,
E.HSE_NAME,
SP.HSPS_NAME,
SP.HSPS_VALUE
FROM
DATABASE SI,
DATABASE E,
DATABASE SP
WHERE
SI.HSS_ID = E.HSE_S_ID AND
E.HSE_ID = SP.HSPS_E_ID AND

((E.HSE_NAME = 'LOGIN' AND
(SP.HSPS_NAME = 'LOCALE' OR SP.HSPS_NAME = 'SESSION_ID' OR SP.HSPS_NAME = 'USER_ID' OR SP.HSPS_NAME = 'SOLD_TO'))
OR
(E.HSE_NAME = 'PAGE_VIEWED' AND
(SP.HSPS_NAME = 'PAGE_NAME' OR SP.HSPS_NAME = 'STATE_ID'))
OR
(E.HSE_NAME = 'LOGOFF'))
ORDER BY
E.HSE_ID, HSE_TIMESTAMP;

SELECT * FROM DBO.MYTABLE;




INSERT INTO DBO.LOGOFFINAL

SELECT DISTINCT EVENT_ID,
EVENT_NAME,
EVENT_VALUE,
EVENT_TIMESTAMP,

EVENT_PARAMETER

FROM DBO.MYTABLE
WHERE EVENT_NAME='LOGOFF'

ORDER BY EVENT_ID
SELECT DISTINCT * FROM DBO.LOGOFFINAL;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top