Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.2 KiB

  1. SET QUOTED_IDENTIFIER ON
  2. GO
  3. SET ANSI_NULLS ON
  4. GO
  5. CREATE PROCEDURE sp_AddBucketFollowup
  6. @i_BucketStr varchar(100),
  7. @i_Followup varchar(50)
  8. AS
  9. BEGIN
  10. DECLARE @iBucket int
  11. DECLARE @iFollowup int
  12. IF NOT EXISTS (SELECT * FROM FollowupIds WHERE Followup = @i_FollowupStr)
  13. BEGIN
  14. INSERT INTO FollowupIds VALUES (@i_FollowupStr)
  15. END
  16. SELECT @iFollowup = @@IDENTITY
  17. -- SELECT @iFollowup = iFollowup FROM FollowupIds WHERE Followup = @i_FollowupStr
  18. IF EXISTS (SELECT iBucket FROM BucketToInt
  19. WHERE BucketId = @i_BucketStr)
  20. BEGIN
  21. -- Bucket exists in bucket table
  22. IF NOT EXISTS (SELECT iBucket FROM BucketToInt b
  23. WHERE BucketId = @i_BucketStr AND b.iFollowup = @iFollowup)
  24. BEGIN
  25. -- Update followup
  26. UPDATE BucketToInt
  27. SET iFollowup = @iFollowup
  28. WHERE iBucket = @iBucket
  29. END
  30. END
  31. ELSE
  32. BEGIN
  33. INSERT INTO BucketToInt (BucketId, iFollowup)
  34. VALUES (@i_BucketStr, @iFollowup)
  35. END
  36. SELECT @i_BucketStr, @iBucket, @iFollowup
  37. -- select * from buckettoint where bucketid = @i_BucketStr
  38. END
  39. GO
  40. SET QUOTED_IDENTIFIER OFF
  41. GO
  42. SET ANSI_NULLS ON
  43. GO