Yes, @ID is a parameter.
Main Topics
Browse All TopicsI'm currently developing an mobile application with SQL Compare Edition 3.5 (SP1).
When I try the execute the following query:
SELECT TOP (1) [Field1] FROM [Table Name] WHERE ([ID] = @ID) OR ([ID] IS NULL AND @ID IS NULL)
This exception was thrown:
The specified argument value for the function is not valid. [ Argument # = 1,Name of function(if known) = isnull ]
When I took off "@ID IS NULL" from the query, it executes correctly. However, the part I took off is required.
Can anyone show me how to compare query's parameter with IS NULL? Or there is any other ways that I can work around, thanks?
p.s. this query works fine on Server edition of SQL Server
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Wow. A search turned up discussions about ISNULL not being supported in SQLCE. I'm amazed.
http://sqlserverce.org/blo
Several mentions of using COALLESCE instead.
Maybe something like:
( COALLESCE([ID],0) = 0 AND COALLESCE(@ID,0) = 0 )
But .... I also saw some mention of problem with COALLESCE and params!If that's the case (easy enough to test by putting in just the [ID] test).
I understand your concern. I'm surprised it doesn't support IS NULL, myself. Having said that, you obviously know what data types you're working with in a given query so there is a workaround, even if it's not as elegant as you'd like. You can certainly coallesce a uniqueidentifier to a varchar. This is an interesting problem. I wish I had CE installed to test this. I noticed you posted out on MSDN yesterday.
Maybe I should explain my question in a different way. Here is a function that I'm creating:
The data type is not bounded in design time (Of course, there is boxing and unboxing issue, but lets ignore for now).
I have tried in the Server Edition of SQL Server, and it works fine. However, when I try in Visual Studio Mobile Device Emulator is doesn't.
One more things is very interesting, when I try the query in Visual Studio with the sdf file, it works too!?
Is it possible that the SQL CE version in the emulator is missing service pack 1?
How do I check it in PC and windows mobile?
Is it a microsoft bug, or we just not suppose to compare query parameter to NULL?
You said this was a sproc, but it's not. It's just dynamic sql. Boxing? Boxing deals with converting value types to/from reference types. Do you mean casting?
If you're having sql parsing errors then why don't you just stop trying to parse them? You are passed in a value (of type object). Why try to pass that into sql, only to have it check to see if it's null? You already know whether it is or not. I really see no reason at all to pass that value in via a param, and considering it's proven problematic, I would have jumped off that horse a while ago.
I'm not even convinced you should be using a parameter in the first place. You're already building dynamic sql, so why build it half dynamic/half parameterized? If you do eliminate the param you might just have to test the object class to see if the value needs to be quoted or not.
Business Accounts
Answer for Membership
by: ToddBeaulieuPosted on 2009-08-10 at 10:17:46ID: 25061858
What is @ID? Param to a sproc? You didn't show the declaration.