﻿<?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 2008 / T-SQL (SS2K8)  / Using a function on SELECT error / 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, 23 May 2013 12:33:23 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using a function on SELECT error</title><link>http://www.sqlservercentral.com/Forums/Topic1406482-392-1.aspx</link><description>Hello Lynn PettisYes, you are right i forget my parameters (bostamp,ref,cor)Thanks for your replyLuis Santos</description><pubDate>Sun, 13 Jan 2013 10:35:01 GMT</pubDate><dc:creator>luissantos</dc:creator></item><item><title>RE: Using a function on SELECT error</title><link>http://www.sqlservercentral.com/Forums/Topic1406482-392-1.aspx</link><description>[quote][b]luissantos (1/13/2013)[/b][hr]Hello comunityI have create this function to return total pairs:CREATE FUNCTION [dbo].[fnQtRefCor](@bostamp varchar(25), @ref varchar(20), @cor varchar(50))RETURNS intASBEGIN	DECLARE @retval int	SELECT @retval = SUM(qtt) FROM bi 	WHERE @bostamp = bostamp AND @ref = ref AND @cor = cor 	and bi.ref &amp;lt;&amp;gt; ''	SET @retval = ISNULL(@retval, 0)	RETURN @retvalENDIf i run this query:SELECT SUM(qtt) FROM bi WHERE bostamp = 'jm13010767476,323000001' AND ref = '2120910'and (bi.ref &amp;lt;&amp;gt; '')group by bi.bostamp,ref,corI obtain the correct value of : 24 if i run this select to test the result :select [dbo].[fnQtRefCor] from bi where bi.bostamp = 'jm13010767476,323000001  'This error appear :Msg 4104, Level 16, State 1, Line 1The multi-part identifier "dbo.fnQtRefCor" could not be bound.I can run this SELECT without error ?Many thanks,Luis Santos[/quote]One thing I see is that you aren't passing in any parameters to the function.Try the following with the proper values for the parameters.select [dbo].[fnQtRefCor](@bostamp  = ??, @ref = ??, @cor= ??);</description><pubDate>Sun, 13 Jan 2013 10:28:41 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: Using a function on SELECT error</title><link>http://www.sqlservercentral.com/Forums/Topic1406482-392-1.aspx</link><description>Sorry, i forget to mencioned that the compatibility level is :SQL SERVER 2000 (80)Maybe the problem is here ??Thanks</description><pubDate>Sun, 13 Jan 2013 10:05:44 GMT</pubDate><dc:creator>luissantos</dc:creator></item><item><title>Using a function on SELECT error</title><link>http://www.sqlservercentral.com/Forums/Topic1406482-392-1.aspx</link><description>Hello comunityI have create this function to return total pairs:CREATE FUNCTION [dbo].[fnQtRefCor](@bostamp varchar(25), @ref varchar(20), @cor varchar(50))RETURNS intASBEGIN	DECLARE @retval int	SELECT @retval = SUM(qtt) FROM bi 	WHERE @bostamp = bostamp AND @ref = ref AND @cor = cor 	and bi.ref &amp;lt;&amp;gt; ''	SET @retval = ISNULL(@retval, 0)	RETURN @retvalENDIf i run this query:SELECT SUM(qtt) FROM bi WHERE bostamp = 'jm13010767476,323000001' AND ref = '2120910'and (bi.ref &amp;lt;&amp;gt; '')group by bi.bostamp,ref,corI obtain the correct value of : 24 if i run this select to test the result :select [dbo].[fnQtRefCor] from bi where bi.bostamp = 'jm13010767476,323000001  'This error appear :Msg 4104, Level 16, State 1, Line 1The multi-part identifier "dbo.fnQtRefCor" could not be bound.I can run this SELECT without error ?Many thanks,Luis Santos</description><pubDate>Sun, 13 Jan 2013 10:02:42 GMT</pubDate><dc:creator>luissantos</dc:creator></item></channel></rss>