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.
Author |
Topic |
bconner
Starting Member
48 Posts |
Posted - 2012-02-21 : 09:34:30
|
I am trying to run a stored procedure in a sequenceBasically I want it to run the following order1. CPC2. 65 Years and Older3. $250.01 To $999.994. GREATER THAN $10005. LESS THAN $250BEGINUPDATE dbo.Tbl_APSET [Work Area] = 'CPC'FROM dbo.Tbl_AP T1WHERE MRN_CPC_ONLY = 'YES' AND [Work Area] IS NULLENDBEGINUPDATE dbo.Tbl_APSET [Work Area] = '65 YEARS AND OLDER'FROM dbo.Tbl_AP T1JOIN dbo.vw_65_And_Older T2 ON T1.[MEDICAL RECORD] = T2.[MEDICAL RECORD]ENDBEGINUPDATE dbo.Tbl_APSET [Work Area] = '$250.01 To $999.99'FROM dbo.Tbl_AP T1JOIN dbo.[vw_250_To_999] T2 ON T1.[MEDICAL RECORD] = T2.[MEDICAL RECORD]WHERE [Work Area] IS NULLENDBEGINUPDATE dbo.Tbl_APSET [Work Area] = 'GREATER THAN $1000'FROM dbo.Tbl_AP T1JOIN dbo.vw_Greater_Than_1000 T2 ON T1.[MEDICAL RECORD] = T2.[MEDICAL RECORD]WHERE [Work Area] IS NULLENDBEGINUPDATE dbo.Tbl_APSET [Work Area] = 'LESS THAN $250'FROM dbo.Tbl_AP T1JOIN dbo.vw_Less_Than_250 T2 ON T1.[MEDICAL RECORD] = T2.[MEDICAL RECORD]WHERE [Work Area] IS NULLEND Brian |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-21 : 09:52:26
|
sorry what is the issue here ? your query is not working ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
bconner
Starting Member
48 Posts |
Posted - 2012-02-21 : 10:06:16
|
I need for the above mentioned queries to run in order 1,2,3...etc.For example there will be some invoices that are CPC with an invoice balance less than $250. If it is CPC I want that to take precedence over it being less than $250 and stamp the invoice CPC.Brian |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-02-21 : 11:00:24
|
The code you have there will run in the sequence they are listed. If that matches the sequence that you want, and you've got where clauses to ensure that a column can't get updated multiple times (which you have in all but the second), then that should work as you want.Does that not happen?--Gail ShawSQL Server MVP |
 |
|
bconner
Starting Member
48 Posts |
Posted - 2012-02-21 : 12:18:15
|
Ok, I feel like a fool! I was looking at the stored procedure on the development machine not the production machine... Sorry... It is working correctly..... I need more sleep and less coffee!Brian |
 |
|
|
|
|