开发者

Why is this function returning 0 rows when the data types are correct?

开发者 https://www.devze.com 2022-12-31 22:21 出处:网络
When the function is defined like this it will return the correct rows. ALTER FUNCTION [dbo].[exampleFuncti开发者_Python百科on](

When the function is defined like this it will return the correct rows.

ALTER FUNCTION [dbo].[exampleFuncti开发者_Python百科on](
 @GUID VARCHAR(20)--NUMERIC(16,0)
,@BrowseName VARCHAR(200)
)

But when I use Numeric(16,0), which is the correct data type for the data that's being passed, I receive 0 rows.

ALTER FUNCTION [dbo].[exampleFunction](
 @GUID NUMERIC(16,0)
,@BrowseName VARCHAR(200)
)

The function is returning a BIT. Basically the function finds the GUID then compares the BrowseTreeName.

Anyone know why this is?

Thanks


just a guess based on your parameter name (@GUID), but a GUID is not actually "numeric", see uniqueidentifier (Transact-SQL). A 16 byte GUID value does not map properly to a numeric(16,0).

Why not just define the @GUID parameter as a uniqueidentifier data type?

0

精彩评论

暂无评论...
验证码 换一张
取 消