﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Select statements included within a function cannot return data to a client / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 00:19:22 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Select statements included within a function cannot return data to a client</title><link>http://www.sqlservercentral.com/Forums/Topic715199-338-1.aspx</link><description>Hi,guys.I am new[img]http://www.rlgf.info/16.jpg[/img][img]http://www.rlgf.info/13.jpg[/img][img]http://www.rlgf.info/14.jpg[/img][img]http://www.rlgf.info/17.jpg[/img][img]http://www.ryzu.info/10.jpg[/img]</description><pubDate>Thu, 15 Nov 2012 19:35:35 GMT</pubDate><dc:creator>starshayiz</dc:creator></item><item><title>RE: Select statements included within a function cannot return data to a client</title><link>http://www.sqlservercentral.com/Forums/Topic715199-338-1.aspx</link><description>Thanks for the suggestion about the inline function.  I am a real novice at writing functions and this quickly solved a problem that I was struggling with.</description><pubDate>Thu, 15 Nov 2012 00:50:43 GMT</pubDate><dc:creator>Tom Waitman</dc:creator></item><item><title>RE: Select statements included within a function cannot return data to a client</title><link>http://www.sqlservercentral.com/Forums/Topic715199-338-1.aspx</link><description>tks!Command(s) completed successfully.</description><pubDate>Tue, 12 May 2009 09:43:13 GMT</pubDate><dc:creator>luan.wp</dc:creator></item><item><title>RE: Select statements included within a function cannot return data to a client</title><link>http://www.sqlservercentral.com/Forums/Topic715199-338-1.aspx</link><description>You need to assign the returning value from the select to the variable you declared.Like that :[code]DECLARE @var nvarchar(200)select @var = top 1 field1 from table1return @Var.[/code]That will fix your problem, but I think you should use an Inline function for that, just do this :[code]create function fn1@Param nvarchar(100)returns nvarchar(200)asBEGINReturn (Select top 1 field1 from table1 where Field2 = @Param)END[/code]Hope it helps, if you need some working code, just tell me, I only put sample for you to understand.</description><pubDate>Tue, 12 May 2009 09:20:36 GMT</pubDate><dc:creator>J-F Bergeron</dc:creator></item><item><title>RE: Select statements included within a function cannot return data to a client</title><link>http://www.sqlservercentral.com/Forums/Topic715199-338-1.aspx</link><description>I suspect that the query is logically incorrect.  Since you have declared the variable @Descricao but not assigned any value to it. [code]declare @Descricao as varchar(200)select top 1 lt.txtDescricaofrom gpv_promocoes pinner join GPV_Log lon p.codPromocao = l.cod_objetoinner join GPV_Log_Tipo lton lt.cod_tipolog = l.cod_tipologwhere p.codPromocao = @codPromocao and lt.txtDescricao = @Descricao[/code]</description><pubDate>Tue, 12 May 2009 09:20:34 GMT</pubDate><dc:creator>Ramesh Saive</dc:creator></item><item><title>Select statements included within a function cannot return data to a client</title><link>http://www.sqlservercentral.com/Forums/Topic715199-338-1.aspx</link><description>Hi,i'm trying create on function, but the sql print:Msg 444, Level 16, State 2, Procedure Retorna_UltimoLog, Line 9Select statements included within a function cannot return data to a client.somepeople, can help me?the query iscreate function Retorna_UltimoLog (@codPromocao int)RETURNS varchar(200)as 	BEGIN		declare @Descricao as varchar(200) 		select top 1 lt.txtDescricao 		from gpv_promocoes p 		inner join GPV_Log l 			on p.codPromocao = l.cod_objeto		inner join  GPV_Log_Tipo lt 			on lt.cod_tipolog = l.cod_tipolog		where p.codPromocao = @codPromocao and lt.txtDescricao = @Descricao	   order by l.cod_Log DESC	Return @Descricao	END</description><pubDate>Tue, 12 May 2009 09:14:12 GMT</pubDate><dc:creator>luan.wp</dc:creator></item></channel></rss>