Hi,
I currently have the following stored procedure;
CREATE PROCEDURE web.insertNewCampaign
(
@tmp_Id BIGINT,
@tmp_Title VARCHAR(100),
@tmp_Content VARCHAR(8000),
@tmp_Pledge DECIMAL(7,2),
--@tmp_Recipients BIGINT,
@tmp_Date DATETIME,
@tmp_Private BIT,
@tmp_Template BIGINT,
@tmp_AddyBook BIGINT
)
AS
declare @recipients BIGINT
declare @tmp_IDENTITY BIGINT
declare @fave BIGINT
declare @allocation VARCHAR(50)
--insert campaign data
BEGIN TRAN
SELECT @recipients = addMaster_NoRecipients FROM tbl_AddressBookMaster
WHERE addMaster_UserId = @tmp_Id AND addMaster_Key = @tmp_AddyBook;
INSERT INTO TBL_CAMPAIGNS ([campaign_MemberId], [campaign_Title], [campaign_Content], [campaign_Pledge], [campaign_Date], [campaign_Private], [campaign_Template], [campaign_AddressBook], [campaign_Recipients])
VALUES (@tmp_Id, @tmp_Title, @tmp_Content, @tmp_Pledge, @tmp_Date, @tmp_Private, @tmp_Template, @tmp_AddyBook, @recipients)
SELECT @tmp_IDENTITY = SCOPE_IDENTITY() --this returns the newly added IDENTITY ID
COMMIT
......
So i have 2 questions:
1) How do i divide @tmp_Pledge by @recipients to give @allocation eg:(@allocation = @tmp_Pledge / @recipients)
2) Is it possible to compound these statements into a more efficient statement(s) with @allocation effectively being inserted as a value into the column [campaign_RecipShare], and reducing the need for these declared variables?
Many Thanks for any help you can offer for either question.
;-)