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
 SQL Server Development (2000)
 Case expressions error

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
Go to Top of Page

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.
Go to Top of Page

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 A
SET 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
end
FROM
[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)
Go to Top of Page

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
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-15 : 17:50:29
11 WHENs
Go to Top of Page

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
Go to Top of Page

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 int
set @x = 399

select x =
case
when @x = 1 then 101
when @x = 2 then 102
when @x = 3 then 103
when @x = 4 then 104
when @x = 5 then 105
when @x = 6 then 106
when @x = 7 then 107
when @x = 8 then 108
when @x = 9 then 109
when @x = 10 then 110
when @x = 11 then 111
when @x = 12 then 112
when @x = 13 then 113
when @x = 14 then 114
when @x = 15 then 115
when @x = 16 then 116
when @x = 17 then 117
when @x = 18 then 118
when @x = 19 then 119
when @x = 20 then 120
when @x = 21 then 121
when @x = 22 then 122
when @x = 23 then 123
when @x = 24 then 124
when @x = 25 then 125
when @x = 26 then 126
when @x = 27 then 127
when @x = 28 then 128
when @x = 29 then 129
when @x = 30 then 130
when @x = 31 then 131
when @x = 32 then 132
when @x = 33 then 133
when @x = 34 then 134
when @x = 35 then 135
when @x = 36 then 136
when @x = 37 then 137
when @x = 38 then 138
when @x = 39 then 139
when @x = 40 then 140
when @x = 41 then 141
when @x = 42 then 142
when @x = 43 then 143
when @x = 44 then 144
when @x = 45 then 145
when @x = 46 then 146
when @x = 47 then 147
when @x = 48 then 148
when @x = 49 then 149
when @x = 50 then 150
when @x = 51 then 151
when @x = 52 then 152
when @x = 53 then 153
when @x = 54 then 154
when @x = 55 then 155
when @x = 56 then 156
when @x = 57 then 157
when @x = 58 then 158
when @x = 59 then 159
when @x = 60 then 160
when @x = 61 then 161
when @x = 62 then 162
when @x = 63 then 163
when @x = 64 then 164
when @x = 65 then 165
when @x = 66 then 166
when @x = 67 then 167
when @x = 68 then 168
when @x = 69 then 169
when @x = 70 then 170
when @x = 71 then 171
when @x = 72 then 172
when @x = 73 then 173
when @x = 74 then 174
when @x = 75 then 175
when @x = 76 then 176
when @x = 77 then 177
when @x = 78 then 178
when @x = 79 then 179
when @x = 80 then 180
when @x = 81 then 181
when @x = 82 then 182
when @x = 83 then 183
when @x = 84 then 184
when @x = 85 then 185
when @x = 86 then 186
when @x = 87 then 187
when @x = 88 then 188
when @x = 89 then 189
when @x = 90 then 190
when @x = 91 then 191
when @x = 92 then 192
when @x = 93 then 193
when @x = 94 then 194
when @x = 95 then 195
when @x = 96 then 196
when @x = 97 then 197
when @x = 98 then 198
when @x = 99 then 199
when @x = 100 then 200
when @x = 101 then 201
when @x = 102 then 202
when @x = 103 then 203
when @x = 104 then 204
when @x = 105 then 205
when @x = 106 then 206
when @x = 107 then 207
when @x = 108 then 208
when @x = 109 then 209
when @x = 110 then 210
when @x = 111 then 211
when @x = 112 then 212
when @x = 113 then 213
when @x = 114 then 214
when @x = 115 then 215
when @x = 116 then 216
when @x = 117 then 217
when @x = 118 then 218
when @x = 119 then 219
when @x = 120 then 220
when @x = 121 then 221
when @x = 122 then 222
when @x = 123 then 223
when @x = 124 then 224
when @x = 125 then 225
when @x = 126 then 226
when @x = 127 then 227
when @x = 128 then 228
when @x = 129 then 229
when @x = 130 then 230
when @x = 131 then 231
when @x = 132 then 232
when @x = 133 then 233
when @x = 134 then 234
when @x = 135 then 235
when @x = 136 then 236
when @x = 137 then 237
when @x = 138 then 238
when @x = 139 then 239
when @x = 140 then 240
when @x = 141 then 241
when @x = 142 then 242
when @x = 143 then 243
when @x = 144 then 244
when @x = 145 then 245
when @x = 146 then 246
when @x = 147 then 247
when @x = 148 then 248
when @x = 149 then 249
when @x = 150 then 250
when @x = 151 then 251
when @x = 152 then 252
when @x = 153 then 253
when @x = 154 then 254
when @x = 155 then 255
when @x = 156 then 256
when @x = 157 then 257
when @x = 158 then 258
when @x = 159 then 259
when @x = 160 then 260
when @x = 161 then 261
when @x = 162 then 262
when @x = 163 then 263
when @x = 164 then 264
when @x = 165 then 265
when @x = 166 then 266
when @x = 167 then 267
when @x = 168 then 268
when @x = 169 then 269
when @x = 170 then 270
when @x = 171 then 271
when @x = 172 then 272
when @x = 173 then 273
when @x = 174 then 274
when @x = 175 then 275
when @x = 176 then 276
when @x = 177 then 277
when @x = 178 then 278
when @x = 179 then 279
when @x = 180 then 280
when @x = 181 then 281
when @x = 182 then 282
when @x = 183 then 283
when @x = 184 then 284
when @x = 185 then 285
when @x = 186 then 286
when @x = 187 then 287
when @x = 188 then 288
when @x = 189 then 289
when @x = 190 then 290
when @x = 191 then 291
when @x = 192 then 292
when @x = 193 then 293
when @x = 194 then 294
when @x = 195 then 295
when @x = 196 then 296
when @x = 197 then 297
when @x = 198 then 298
when @x = 199 then 299
when @x = 200 then 300
else 2
end

Results:

x
-----------
2

(1 row(s) affected)




CODO ERGO SUM
Go to Top of Page

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.
Go to Top of Page

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.
Go to Top of Page

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.
Go to Top of Page

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
Go to Top of Page

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?
Go to Top of Page

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 porvider

B is using the Microsoft jet 4.0 oledb provider

i hope that helps
Go to Top of Page

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 porvider

B 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.


Go to Top of Page
   

- Advertisement -