Hello
Once i have created a new query and it all works fine I save the query and then I run into trouble. When I come to re use the query at a later date it dosen't work and brings up the following error.
Msg 208, Level 16, State 1, Line 15
Invalid object name 'kup_regions'.
which equates to this line -
if (select sitetype from kup_regions where region_code = @.Location) = 10
I am using 'sa' as my username and sql server management studio
Cheers for any help
hi,
SimonJohns wrote:
Hello
Once i have created a new query and it all works fine I save the query and then I run into trouble. When I come to re use the query at a later date it dosen't work and brings up the following error.
Msg 208, Level 16, State 1, Line 15
Invalid object name 'kup_regions'.
which equates to this line -
if (select sitetype from kup_regions where region_code = @.Location) = 10
I am using 'sa' as my username and sql server management studio
Cheers for any help
assuming the kup_regions table/view exists at successive call in the current database, I'd just try with the complete object's name, that's the schemaName.objectName, in order to avoid eventual different default schema problems among different database users.. so it all becomes
IF (SELECT sitetype FROM dbo.kup_regions WHERE region_code = @.Location ) = 10 BEGIN-- whatever
END;
but I see a side effect if region_code is not a "unique" value in the underlying table... if this is the case, your code will actually fail with
"Msg 512, Level 16, State 1, Line 10
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."
exception...
regards
No comments:
Post a Comment