New feature! Upgrade and increase expert visibility of your issues with Priority Questions.
CREATE PROC [dbo].[sp_SiteUpdate]( @PaymentID nvarchar(50)) AS --SET NOCOUNT ON DECLARE @LeanLoadID nvarchar(50) DECLARE @InvoiceSite nvarchar(50) DECLARE @GroupInfo nvarchar(50) DECLARE @RowsAffected int SET @RowsAffected = 0 DECLARE invoicesite_cursor CURSOR FOR SELECT leanloadID FROM PAYMENT LP,LOAD LL WHERE LP.PAYMENTID = LL.PAYMENTID AND LP.PAYMENTID = @PaymentID ORDER BY LL.LEANLOADID OPEN invoicesite_cursor WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM invoicesite_cursor INTO @LeanLoadID SELECT @InvoiceSite = S.LOCATIONREF,@GroupInfo = GROUPINFORMATION FROM LEANWS_LOAD L LEFT OUTER JOIN (SELECT LOCATIONREF,LEANLOADID FROM STOP WHERE LOCATIONREF IN('1','2','3') AND LEANLOADID = @LeanLoadID) AS S ON L.LEANLOADID = S.LEANLOADID WHERE L.LEANLOADID = @LeanLoadID SET @InvoiceSite = ISNULL(@InvoiceSite,0) IF @InvoiceSite = '1' SET @InvoiceSite = 'TXHQ' ELSE IF @InvoiceSite = '2' SET @InvoiceSite = 'KNOX' ELSE IF @InvoiceSite = '3' SET @InvoiceSite = 'ARIZ' ELSE SET @InvoiceSite = @GroupInfo UPDATE LOAD SET INVOICESITE = @InvoiceSite WHERE LEANLOADID = @LeanLoadID SET @RowsAffected = @@ROWCOUNT END CLOSE invoicesite_cursor DEALLOCATE invoicesite_cursor
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.