About
Pricing
Community
Teams
Start Free Trial
Log in
Destiny Amana
asked on
6/1/2007
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 2005
ASP
5
1
Last Comment
golfDoctor
8/22/2022 - Mon
L00M
6/1/2007
What database are you using?
Destiny Amana
6/1/2007
ASKER
MSSQL 2005
ASKER CERTIFIED SOLUTION
L00M
6/1/2007
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
6/1/2007
Oh yes... the asp code:
<%
Set cn = Server.CreateObject("ADODB
.Connectio
n")
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
6/1/2007
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)
%>