﻿<?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 / SQL Server Newbies  / function in a sql statement / 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>Wed, 22 May 2013 01:02:40 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>This is the classic behaviour I wanted to point to in my warnings[url]http://www.sqlservercentral.com/Forums/Topic567766-8-1.aspx[/url]</description><pubDate>Sun, 14 Sep 2008 08:04:55 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>Indeed. Also keep in mind functions are directly available to any sql statement, not only from within a stored procedure.Also keep in mind you need to provide the actual schema for the functionSelect [Company Name],Patient,Visit,[Visit Date],[Insurance Company],[b]dbo.[/b]InsPolicyVal(A.Visit)  -- this is the  function which should return valuefrom [Medical Visit] A ON H.Patient = A.Patient INNER JOIN      [Payment Policies] C ON A.[Insurance Policy] = C.Policy INNER JOIN      [Medical Policy Link] D ON C.EmployerInsuranceLink = D.ID INNER JOIN  dbo.[Insurance Companies] E ON D.[Insurance Company ID] = E.[Insurance Company] </description><pubDate>Sun, 07 Sep 2008 23:54:23 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>ALZDBA, I will have to take your word for it as I haven't read those articles.  I can see what you are saying though if you are calling numerous functions inside of a store proc.  That would be difficult to diagnose performance issues.</description><pubDate>Sun, 07 Sep 2008 18:47:28 GMT</pubDate><dc:creator>Fraggle-805517</dc:creator></item><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>[quote][b]Fraggle (9/7/2008)[/b][hr]It has always been my policy to used functions to replace repetative coding.  Why do I need to continually type to code out to verify that a customer is active when I can put it in a function and type out less than a line of code to do it.  To me this is really the best use of a function.[/quote]It may indeed server you well, for now.:doze:There are a number of articles at SSC which handle set based operations and try to explain the issues with hidden joins, row by row operations (rbar), ...I'd prefer a view over a function, because it still points the problem solving dba by nature to join analysis and troubleshooting.A single function in your query may be easy to detect and analyse, but the number of functions you use in a single query can be huge, now figure the out the troubleshooting part.</description><pubDate>Sun, 07 Sep 2008 09:51:07 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>It has always been my policy to used functions to replace repetative coding.  Why do I need to continually type to code out to verify that a customer is active when I can put it in a function and type out less than a line of code to do it.  To me this is really the best use of a function.</description><pubDate>Sun, 07 Sep 2008 07:12:46 GMT</pubDate><dc:creator>Fraggle-805517</dc:creator></item><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>Why would you want to use a function if you can do a join ?????Most of the time it's these kind of functions that mess up response times in your applications.. blaming sqlserver..Making it hard to discover, fine tune, problem solve,.... hidden joins are one of the worst.</description><pubDate>Sun, 07 Sep 2008 03:47:12 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>You need to call it using a two part identifier.  In this case it is probably dbo.InsPolVal(data).  If the function has a schema, use that in replacement of the dbo.  (policy.InsPolVal)Also, unless I am much mistaken if your function is returning more than 1 value, you cannot use it in a select statement.  It must be a scalar value function to be used in the select statement.Hope that helps</description><pubDate>Sat, 06 Sep 2008 12:53:56 GMT</pubDate><dc:creator>Fraggle-805517</dc:creator></item><item><title>RE: function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>Hello,Is InsPolicyVal a Scalar or Table function? If it’s Scalar then you should be able to use it as in your example. If it is a Table function then you would probably want to include it in a Join.Regards,John Marsh</description><pubDate>Sat, 06 Sep 2008 05:58:32 GMT</pubDate><dc:creator>John H Marsh </dc:creator></item><item><title>function in a sql statement</title><link>http://www.sqlservercentral.com/Forums/Topic565013-1291-1.aspx</link><description>How can the function be used in MS SQL.I have afunction which retruns value &amp; date.I would like to use this to fetch records which I do in Oracle.I am not sure how this can be done in MS SQLIts like this Select [Company Name],Patient,Visit,[Visit Date],[Insurance Company],InsPolicyVal(A.Visit)  -- this is the  function which should return valuefrom [Medical Visit] A ON H.Patient = A.Patient INNER JOIN      [Payment Policies] C ON A.[Insurance Policy] = C.Policy INNER JOIN      [Medical Policy Link] D ON C.EmployerInsuranceLink = D.ID INNER JOIN  dbo.[Insurance Companies] E ON D.[Insurance Company ID] = E.[Insurance Company] the InsPolicyVal is the function which should retrun the insurance value for a specific visit.I have tried using Outer join but the out does not seem to be correct.Please if some one can help.</description><pubDate>Sat, 06 Sep 2008 05:44:20 GMT</pubDate><dc:creator>mathewspsimon</dc:creator></item></channel></rss>