Avatar of Destiny Amana
Destiny Amana
Flag for Nigeria asked on

Triggering a stored procedure to copy from one tble to another using ASP.

INSERT INTO [dbo].[messagelog_archive]
  SELECT * FROM [dbo].[messagelog]
  WHERE [DateSent] < DateAdd(m,-3,getdate())

DELETE [dbo].[messagelog]
  WHERE  SN in
   (Select SN from [dbo].[messagelog_archive])
 

I would like to implement this as a stored procedure that I can call from an ASP page, how would I get that done
Microsoft SQL Server 2005ASP

Avatar of undefined
Last Comment
golfDoctor

8/22/2022 - Mon
L00M

What database are you using?
Destiny Amana

ASKER
MSSQL 2005
ASKER CERTIFIED SOLUTION
L00M

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
L00M

Oh yes... the asp code:

  <%
   Set cn = Server.CreateObject("ADODB.Connection")
   cn.Open "data source name", "userid", "password"
   Set cmd = Server.CreateObject("ADODB.Command")
   Set cmd.ActiveConnection = cn
   cmd.CommandText = "YourSprocName"
   cmd.CommandType = adCmdStoredProc
   cmd.Execute
   %>
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
golfDoctor

So you know, you could just run that like this:

<%
sql = "INSERT INTO [dbo].[messagelog_archive] " & vbcrlf & _
         " SELECT * FROM [dbo].[messagelog] " & vbcrlf & _
  "WHERE [DateSent] < DateAdd(m,-3,getdate()) " & vbcrlf & _
"DELETE [dbo].[messagelog] " & vbcrlf & _
  "WHERE  SN in " & vbcrlf & _
   "(Select SN from [dbo].[messagelog_archive])"

myconnection.execute(sql)
%>