StackOverflowDocumentation
.dbo
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
usp_insertVotes
Parameters
Name
Type
Mode
Definition
CREATE PROC [dbo].[usp_insertVotes] AS BEGIN -- set up variables to randomly determine the votetype up (2) or down (3) DECLARE @voteTypeId INT = NULL; /* variable for vote type id*/ /* Determine count of users added within the workload recorded This is a helper to get the workload and the inserts deterministic rather than having random inputs */ DECLARE @count INT = (SELECT COUNT(*) FROM dbo.Votes WHERE CreationDate > '20200512') + 1; -- let's be positive and achieve 2/3 positive votes (type 2) and 1/3 negative votes (type 3) IF (@count%3 = 0 OR @count%3=1) SET @voteTypeId = 2; IF (@count%3 = 2) SET @voteTypeId = 3; -- debugging select INSERT INTO dbo.Votes ( PostId, UserId, VoteTypeId, CreationDate ) VALUES ( /* -- randomly return one of the newly generated posts ( SELECT TOP 1 id FROM dbo.Posts --WHERE CreationDate > '20200501' ORDER BY NEWID() )*/ 4315748, -- PostId - int 61636 -- one users does all the votes for the workload to be deterministic /* -- randomly return one of the users ( SELECT TOP 1 id FROM dbo.Users ORDER BY NEWID() )*/, -- UserId - int @voteTypeId, -- VoteTypeId - int 2 UpVote / 3 DownVote '20200512 18:15' -- CreationDate - datetime ) ; END