Home > Archive > Microsoft SQL Server forum > June 2005 > SQL 2005 testing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQL 2005 testing
carey.loomis@gmail.com

2005-06-10, 1:23 pm

I've begun some testing with the June beta of SQL 2005. One problem
I've hit is with scalar-valued functions. The error I often get when
executing functions is "Select statements included within a function
cannot return data to a client.". These same functions are working
fine under SQL 2000.

Has anybody seen this behavior or know what the deal is?

Serge Rielau

2005-06-10, 1:23 pm

carey.loomis@gmail.com wrote:
> I've begun some testing with the June beta of SQL 2005. One problem
> I've hit is with scalar-valued functions. The error I often get when
> executing functions is "Select statements included within a function
> cannot return data to a client.". These same functions are working
> fine under SQL 2000.
>
> Has anybody seen this behavior or know what the deal is?
>

Doesn't a SELECT inside of a routine return a result set to the caller?
What would be the effect of doing this inside, say, a function in a
WHERE clause. You may want to assign the result of that select to a
local variable...

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
carey.loomis@gmail.com

2005-06-10, 8:23 pm

Serge,
Yes, I do assign the results of the select to a local variable. These
functions are simple and I'm not having trouble with how to use
functions. The problem is they work with SQL 2000 but produce errors
with SQL 2005. Here is an example of one of the functions.

create function dbo. vfVendorName(@Subscr
iberID int, @ApplicationNum
int)
returns varchar(100)
as
BEGIN
declare @rtn varchar(100)
select @rtn=Vendorname from vAppVendor
where SubscriberID=@Subscr
iberID and ApplicationNum=@Appl
icationNum
return @rtn
end

Works fine when called from SQL 2000 but gives "Select statements
included within a function cannot return data to a client." when run
from SQL 2005.

David Portas

2005-06-10, 8:23 pm

Inside a function you are not permitted to execute a SELECT statement that
returns data to the client. Could you post an example of a function that
returns this error in SQL2005 but not in SQL2000.

--
David Portas
SQL Server MVP
--

<carey.loomis@gmail.com> wrote in message
news:1118425681.571843.266240@g44g2000cwa.googlegroups.com...
> I've begun some testing with the June beta of SQL 2005. One problem
> I've hit is with scalar-valued functions. The error I often get when
> executing functions is "Select statements included within a function
> cannot return data to a client.". These same functions are working
> fine under SQL 2000.
>
> Has anybody seen this behavior or know what the deal is?
>



Erland Sommarskog

2005-06-10, 8:23 pm

carey.loomis@gmail.com (carey.loomis@gmail.com) writes:
> Yes, I do assign the results of the select to a local variable. These
> functions are simple and I'm not having trouble with how to use
> functions. The problem is they work with SQL 2000 but produce errors
> with SQL 2005. Here is an example of one of the functions.
>
> create function dbo. vfVendorName(@Subscr
iberID int, @ApplicationNum
> int)
> returns varchar(100)
> as
> BEGIN
> declare @rtn varchar(100)
> select @rtn=Vendorname from vAppVendor
> where SubscriberID=@Subscr
iberID and ApplicationNum=@Appl
icationNum
> return @rtn
> end
>
> Works fine when called from SQL 2000 but gives "Select statements
> included within a function cannot return data to a client." when run
> from SQL 2005.


I rewrote your function as:

create function dbo.blafs(@OrderID int, @EmployeeID int)
returns varchar(100)
as
BEGIN
declare @rtn nvarchar(100)
select @rtn = CustomerID from Northwind..Orders
where OrderID = @OrderID and EmployeeID = @EmployeeID
return @rtn
end
go
SELECT dbo.blafs (10988, 3)
go

Since I only changed table and column names to a database that I have
available, this function should yield the same result as yours. However,
I seem to recall that I have seen a similar problem discussed in the
beta newsgroups, so there might be an issue somewhere.

Anyway, this is not the place where you should discuss SQL 2005.
Please see http://go.microsoft.com/fwlink/?linkid=31765 for access
information to the beta newsgroups for SQL 2005. This is because
these groups are frequented by more SQL Server developers than
this newsgroup.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
carey.loomis@gmail.com

2005-06-13, 1:23 pm

Erland,
Thanks for pointing me to correct newsgroup. I'll post my issue there.
I do believe this is an issue with sql 2005 as I have several
functions which do the same type of retrieval - some work and some
don't, yet they all work fine on sql 2000
Carey Loomis

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com