Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Running 5 commands together

Author  Topic 

QuietRiot
Yak Posting Veteran

67 Posts

Posted - 2009-03-11 : 20:07:22


Easy question. If I wanted to run the 5 commands together what would be the best way of doing it? Can I put GO in between?


-- 7 rows
UPDATE FundTransactionLines
SET SuppressVoidsFlag = 0
WHERE TransactionID in (98482,98486,98487,98615,98638,98634,98681)
AND FundTransactionLineno = 1

-- 4 rows
UPDATE FundTransactionLines
SET SuppressVoidsFlag = 0
WHERE TransactionID in (98490)
AND FundTransactionLineno in (13, 15, 21, 23)

-- 18 rows
UPDATE FundTransactionLines
SET SuppressVoidsFlag = 0
WHERE TransactionID in (98482,98782,98705,98707,98732,98741,98766,98779,98787,98812,98828,98831,98834,98845,98869,98904,98919,98926)
AND FundTransactionLineno = 3

-- 3 rows
UPDATE FundTransactionLines
SET SuppressVoidsFlag = 0
WHERE TransactionID in (98482,98492,98784)
AND FundTransactionLineno = 5

-- 2 rows
UPDATE FundTransactionLines
SET SuppressVoidsFlag = 0
WHERE TransactionID in (98482)
AND FundTransactionLineno in (7,9)

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-03-11 : 21:30:07
Yeah u can use GO.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-03-11 : 22:33:31
Why can't you incorporate them into 1 transaction and run?
Go to Top of Page

QuietRiot
Yak Posting Veteran

67 Posts

Posted - 2009-03-11 : 23:32:31
quote:
Originally posted by sodeep

Why can't you incorporate them into 1 transaction and run?



I made it 5 different sets because for example on the 2nd one there is a line 13 and I wouldn't want any of the TransactionID's in the first set to update line 13.

Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-17 : 07:57:54
But I thought you wanted to run them together. So, The result will be the same.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-03-17 : 08:16:31
You can do this in one UPDATE statement:

UPDATE FundTransactionLines
SET SuppressVoidsFlag = 0
WHERE (TransactionID in (98482,98486,98487,98615,98638,98634,98681) AND FundTransactionLineno = 1)
OR (TransactionID in (98490) AND FundTransactionLineno in (13, 15, 21, 23))
OR (TransactionID in (98482,98782,98705,98707,98732,98741,98766,98779,98787,98812,98828,98831,98834,98845,98869,98904,98919,98926) AND FundTransactionLineno = 3)
OR (TransactionID in (98482,98492,98784) AND FundTransactionLineno = 5)
OR (TransactionID in (98482) AND FundTransactionLineno in (7,9))

Go to Top of Page
   

- Advertisement -