Wednesday, March 7, 2012

Does CLNG work in Sql Compact?

Hi,

When I execute following query against to SqlCE 3.0.53, I am getting an error, could someone guide where it is wrong.

SELECT SLCTD_MENUENTRYID FROM GEN_ENTRY WHERE EXAMID = 'EFBC0657145840CF88184BDCE71430EE'

AND TYPEVALUE IN ('SURG_PROC', 'CV_PROC') AND CLNG(SLCTD_MENUENTRYID) < 0

Error:

Major Error 0x80040E14, Minor Error 25921

> SELECT SLCTD_MENUENTRYID FROM GEN_ENTRY WHERE EXAMID = 'EFBC0657145840CF88184BDCE71430EE'

AND TYPEVALUE IN ('SURG_PROC', 'CV_PROC') AND CLNG(SLCTD_MENUENTRYID) < 0

The function is not recognized by SQL Server Compact Edition. [ Name of function = CLNG,Data type (if known) = ]

CLNG is not availabel in SQL CE. For documention on the SQL CE SQL syntax, see http://msdn2.microsoft.com/en-us/library/ms173372.aspx. You could use CONVERT(int, SLCTD_MENUENTRYID) instead.

|||I feel the above CONVERT function always returns non fractional value.

For ex:
select CONVERT(int, 4.7)= 4
select CONVERT(int, 4.4)=4
select CONVERT(int, -4.7) =-4
select CONVERT(int, -4.4) =-4

But where as CLNG function does the following:
select CLNG(4.7)=5
select CLNG(4.4)=4
select CLNG(-4.7)=-5
select CLNG(-4.4)=-4

I feel the following line will work for us:

select CONVERT(int, round(4.7,0)) =5
select CONVERT(int, round(4.4,0)) =4
select CONVERT(int, round(-4.7,0)) =-5
select CONVERT(int, round(-4.4,0)) =-4

Please let me know if I am wrong.

Thanks|||If that works for you, you are of course right. CLNG is not available in SQL CE, but other conversion functions are.

No comments:

Post a Comment