MS-SQL Stored Procedure help
- or -
Post a project like this3504
£10(approx. $13)
- Posted:
- Proposals: 0
- Remote
- #555747
- Awarded
Description
Experience Level: Entry
General information for the business: DB Work
Database management system (DBMS): Microsoft SQL Server
Description of requirements/functionality: I have the SP below. At the moment it inserts a new row each time.
I want to change that so if cookie,domain,page,referrer,useragent,ipaddress match an existing row in the DB, and the datetimelast is within 10 seconds, it will update that row and set the datetimelast to current datetime, otherwise insert a new row as it does now.
Thanks
CREATE proc [dbo].[spJTrack]
(
@cookie varchar(50) = null,
@domain varchar(50) = null,
@page varchar (MAX) = null,
@referrer varchar (MAX) = null,
@useragent varchar (MAX) = null,
@ipaddress varchar (50) = null
)
AS
INSERT INTO JTrack (
cookie,
domain,
page,
referrer,
useragent,
ipaddress,
datetimestart,
datetimelast
) VALUES (
@cookie,
@domain,
@page,
@referrer,
@useragent,
@ipaddress,
GETDATE(),
GETDATE()
)
SELECT @@IDENTITY
Extra notes:
Database management system (DBMS): Microsoft SQL Server
Description of requirements/functionality: I have the SP below. At the moment it inserts a new row each time.
I want to change that so if cookie,domain,page,referrer,useragent,ipaddress match an existing row in the DB, and the datetimelast is within 10 seconds, it will update that row and set the datetimelast to current datetime, otherwise insert a new row as it does now.
Thanks
CREATE proc [dbo].[spJTrack]
(
@cookie varchar(50) = null,
@domain varchar(50) = null,
@page varchar (MAX) = null,
@referrer varchar (MAX) = null,
@useragent varchar (MAX) = null,
@ipaddress varchar (50) = null
)
AS
INSERT INTO JTrack (
cookie,
domain,
page,
referrer,
useragent,
ipaddress,
datetimestart,
datetimelast
) VALUES (
@cookie,
@domain,
@page,
@referrer,
@useragent,
@ipaddress,
GETDATE(),
GETDATE()
)
SELECT @@IDENTITY
Extra notes:
Ben D.
100% (27)Projects Completed
23
Freelancers worked with
24
Projects awarded
53%
Last project
7 Oct 2019
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies