SQL Server BUG Set “-defined functions and group by”
/**==** 1. Custom function for the group by error **==**/
— A simple function
Create function f_str (@ str sysname, @ i int)
Returns char (1)
As begin
Return (substring (str @, @ i, 1))
End
Go
— Below are the test
— Definition of the test data
Declare @ t table (name sysname)
Insert into @ t values ( 'abcd')
— A group by the situation, the wrong results
Select a = dbo.f_str (name, 1), b = dbo.f_str (name, 2)
From @ t
Group by dbo.f_str (name, 1), dbo.f_str (name, 2)
— No group by the situation, the correct results
Select a = dbo.f_str (name, 1), b = dbo.f_str (name, 2)
From @ t
Go
— Delete test-defined functions
Drop function f_str
/ Op test results
A b
—- —-
A a
(Number of rows affected by the line 1)
A b
—- —-
A b
(Number of rows affected by the line 1)
–* /
Tags: bug, SQL SERVER








0 Comments to “SQL Server BUG Set “-defined functions and group by””
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.