Jeff, it would look something like this:@userPk INT,
@eventLocationPk BIGINT
AS
BEGIN
-- Turn off row counting
SET NOCOUNT ON;
-- Declare variables
DECLARE @recCount INT;
-- Perform a scalar query to determine if the
-- record already exists
SELECT
@recCount = COUNT(* )
FROM UserLocations
WHERE ul_us_pk = @userPk
-- Now determine how to update the record
IF @recCount > 0
BEGIN
-- Update the existing record
UPDATE UserLocations
SET ul_vel_pk = @eventLocationPk
WHERE ul_us_pk = @userPk
END
ELSE
BEGIN
-- Create the location record
INSERT INTO UserLocations (
ul_us_pk,
ul_vel_pk)
VALUES (
@userPk,
@eventLocationPk)
END
END