Author |
Topic |
soorma
Yak Posting Veteran
52 Posts |
Posted - 2006-11-15 : 16:28:19
|
I have a linked server and i am trying to do an update. The stored proc have case statements. when ever i run the stored proc i get an error Case expressions may only be nested to level 10. i have 11 case statements. if i comment out the last case statement it works fine. The funny thing is if i run proc from another linked server it runs fine. example Both A and B servers are linked to C. The proc runs fine on A but not on B. |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-11-15 : 16:37:39
|
do all servers have same service packs?care to show us the query?Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2006-11-15 : 16:49:35
|
Are all versions of sql the same? I think that was a limitation on MSDE,not Sql Server. |
 |
|
soorma
Yak Posting Veteran
52 Posts |
Posted - 2006-11-15 : 17:27:54
|
Both the SQL server are same. I don't know about the packs though. Here is the Query. I have hardcodded some stuff. But u will get an idea.Declare @usersemail varchar(50)Declare @Status varchar(50)Declare @location varchar(50)SELECT @Status=part_status,@location=loc_region, @usersemail= SUBSTRING(loc_bus_email,NULLIF(CHARINDEX('@', loc_bus_email), 0) + 1,LEN(loc_bus_email) - CHARINDEX('@', loc_bus_email) + 1)FROM LOCATION INNER JOIN PARTNER ON LOCATION.part_id = PARTNER.part_id where PARTNER.part_id ='0000000'set @status ='platinum'set @location = 'southaus'UPDATE ASET RoleId = Case when @Status = 'Silver' and (@location ='italy' or @location ='belgium' or @location ='uk') then 8 when @Status = 'Gold' and (@location ='italy' or @location ='belgium' or @location ='uk') then 4 when @Status = 'Platinum' and (@location ='italy' or @location ='belgium' or @location ='uk') then 3 when @Status = 'VAD' and (@location ='italy' or @location ='belgium' or @location ='uk') then 15 when @Status = 'Platinum' and (@location ='asia' or @location ='northaus' or @location ='southaus') then 10 when @Status = 'gold' and (@location ='asia' or @location ='northaus' or @location ='southaus') then 11 when @Status = 'silver' and (@location ='asia' or @location ='northaus' or @location ='southaus') then 12 when @Status = 'VAD' and (@location ='asia' or @location ='northaus' or @location ='southaus') then 16 when @Status = 'Platinum' and (@location ='can' or @location ='gl'or @location ='latinam') then 13 when @Status = 'gold' and (@location ='can' or @location ='gl' or @location ='latinam') then 14 when @Status = 'Stagnant' then 9 endFROM[my.server].hello.dbo.UserRoles As A WHERE RoleId in (3,4,8,10,11,12,13,14,15,16,9)and userid in (select UserID from [my.server].hello.dbo.users where USERNAME like '%' + @usersemail) |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-11-15 : 17:46:25
|
I only see one CASE statement in that code, not 11.CODO ERGO SUM |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-11-15 : 17:50:29
|
11 WHENs |
 |
|
soorma
Yak Posting Veteran
52 Posts |
Posted - 2006-11-15 : 18:57:29
|
Yup 11 Whens. when i commnet out the last when statament it works |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-11-15 : 20:55:09
|
quote: Originally posted by soorma Yup 11 Whens. when i commnet out the last when statament it works
You have some other problem. This works fine for me.declare @x intset @x = 399select x =casewhen @x = 1 then 101when @x = 2 then 102when @x = 3 then 103when @x = 4 then 104when @x = 5 then 105when @x = 6 then 106when @x = 7 then 107when @x = 8 then 108when @x = 9 then 109when @x = 10 then 110when @x = 11 then 111when @x = 12 then 112when @x = 13 then 113when @x = 14 then 114when @x = 15 then 115when @x = 16 then 116when @x = 17 then 117when @x = 18 then 118when @x = 19 then 119when @x = 20 then 120when @x = 21 then 121when @x = 22 then 122when @x = 23 then 123when @x = 24 then 124when @x = 25 then 125when @x = 26 then 126when @x = 27 then 127when @x = 28 then 128when @x = 29 then 129when @x = 30 then 130when @x = 31 then 131when @x = 32 then 132when @x = 33 then 133when @x = 34 then 134when @x = 35 then 135when @x = 36 then 136when @x = 37 then 137when @x = 38 then 138when @x = 39 then 139when @x = 40 then 140when @x = 41 then 141when @x = 42 then 142when @x = 43 then 143when @x = 44 then 144when @x = 45 then 145when @x = 46 then 146when @x = 47 then 147when @x = 48 then 148when @x = 49 then 149when @x = 50 then 150when @x = 51 then 151when @x = 52 then 152when @x = 53 then 153when @x = 54 then 154when @x = 55 then 155when @x = 56 then 156when @x = 57 then 157when @x = 58 then 158when @x = 59 then 159when @x = 60 then 160when @x = 61 then 161when @x = 62 then 162when @x = 63 then 163when @x = 64 then 164when @x = 65 then 165when @x = 66 then 166when @x = 67 then 167when @x = 68 then 168when @x = 69 then 169when @x = 70 then 170when @x = 71 then 171when @x = 72 then 172when @x = 73 then 173when @x = 74 then 174when @x = 75 then 175when @x = 76 then 176when @x = 77 then 177when @x = 78 then 178when @x = 79 then 179when @x = 80 then 180when @x = 81 then 181when @x = 82 then 182when @x = 83 then 183when @x = 84 then 184when @x = 85 then 185when @x = 86 then 186when @x = 87 then 187when @x = 88 then 188when @x = 89 then 189when @x = 90 then 190when @x = 91 then 191when @x = 92 then 192when @x = 93 then 193when @x = 94 then 194when @x = 95 then 195when @x = 96 then 196when @x = 97 then 197when @x = 98 then 198when @x = 99 then 199when @x = 100 then 200when @x = 101 then 201when @x = 102 then 202when @x = 103 then 203when @x = 104 then 204when @x = 105 then 205when @x = 106 then 206when @x = 107 then 207when @x = 108 then 208when @x = 109 then 209when @x = 110 then 210when @x = 111 then 211when @x = 112 then 212when @x = 113 then 213when @x = 114 then 214when @x = 115 then 215when @x = 116 then 216when @x = 117 then 217when @x = 118 then 218when @x = 119 then 219when @x = 120 then 220when @x = 121 then 221when @x = 122 then 222when @x = 123 then 223when @x = 124 then 224when @x = 125 then 225when @x = 126 then 226when @x = 127 then 227when @x = 128 then 228when @x = 129 then 229when @x = 130 then 230when @x = 131 then 231when @x = 132 then 232when @x = 133 then 233when @x = 134 then 234when @x = 135 then 235when @x = 136 then 236when @x = 137 then 237when @x = 138 then 238when @x = 139 then 239when @x = 140 then 240when @x = 141 then 241when @x = 142 then 242when @x = 143 then 243when @x = 144 then 244when @x = 145 then 245when @x = 146 then 246when @x = 147 then 247when @x = 148 then 248when @x = 149 then 249when @x = 150 then 250when @x = 151 then 251when @x = 152 then 252when @x = 153 then 253when @x = 154 then 254when @x = 155 then 255when @x = 156 then 256when @x = 157 then 257when @x = 158 then 258when @x = 159 then 259when @x = 160 then 260when @x = 161 then 261when @x = 162 then 262when @x = 163 then 263when @x = 164 then 264when @x = 165 then 265when @x = 166 then 266when @x = 167 then 267when @x = 168 then 268when @x = 169 then 269when @x = 170 then 270when @x = 171 then 271when @x = 172 then 272when @x = 173 then 273when @x = 174 then 274when @x = 175 then 275when @x = 176 then 276when @x = 177 then 277when @x = 178 then 278when @x = 179 then 279when @x = 180 then 280when @x = 181 then 281when @x = 182 then 282when @x = 183 then 283when @x = 184 then 284when @x = 185 then 285when @x = 186 then 286when @x = 187 then 287when @x = 188 then 288when @x = 189 then 289when @x = 190 then 290when @x = 191 then 291when @x = 192 then 292when @x = 193 then 293when @x = 194 then 294when @x = 195 then 295when @x = 196 then 296when @x = 197 then 297when @x = 198 then 298when @x = 199 then 299when @x = 200 then 300else 2end Results:x ----------- 2(1 row(s) affected) CODO ERGO SUM |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-11-15 : 21:05:56
|
It seems strange that it is not a more widely reported problem, but I get the impression that it happens with linked servers, rather specific versions? Can you test it on the linked server - I'll bet it will work fine. |
 |
|
soorma
Yak Posting Veteran
52 Posts |
Posted - 2006-11-16 : 11:35:10
|
It works fine on the linked server. kind of weird. Do we have an answer. |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-11-16 : 12:21:48
|
I just tried it with a linked server and got the same message, so it looks like we have an undocumented limitation. |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-11-16 : 13:45:28
|
What provider is the linked server using where you got the error?CODO ERGO SUM |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-11-16 : 13:58:28
|
Standard SQL Server one that gets used when you set up the linked server in Enterprise Manager. I just selected the SQL Server radio button. I think that means its using the latest version of the OLE DB provider? |
 |
|
soorma
Yak Posting Veteran
52 Posts |
Posted - 2006-11-16 : 14:10:44
|
I have two servers A and B and i created a link server on both A and B to C.The code works fine on A which is using microsoft isam 1.1 oledb porviderB is using the Microsoft jet 4.0 oledb provider i hope that helps |
 |
|
Maxer
Yak Posting Veteran
51 Posts |
Posted - 2007-06-08 : 14:33:01
|
quote: Originally posted by soorma I have two servers A and B and i created a link server on both A and B to C.The code works fine on A which is using microsoft isam 1.1 oledb porviderB is using the Microsoft jet 4.0 oledb provider i hope that helps
I ran into the same problem myself running a query over a linked server (2000) with my local server being 2005. Anyone have any information about a work around (hope I'm not resurrecting a thread that is too far dead)Thanks. |
 |
|
|