Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!
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.
|How do I find out to see if there is any open transaction in DB2 database ?||2||32|
|Click print button programmatically on print showdialog||1||24|
|T-SQL: need to reset a declared variable||4||31|
|SQL Server Pivot||5||39|
Join the community of 500,000 technology professionals and ask your questions.