<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; 2005 &#8211; Use of Non-deterministic Function in UDF &#8211; Find Day Difference Between Any Date and Today</title>
	<atom:link href="http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: m0thmanUD</title>
		<link>http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-51786</link>
		<dc:creator>m0thmanUD</dc:creator>
		<pubDate>Mon, 11 May 2009 17:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-51786</guid>
		<description>This is a real pain.  I wanted to use RAND() in a UDF I was putting together to generate random URL keys and hit a brick wall with this.

I know there&#039;s a few workarounds, such as having the RAND in a view, or just using a stored proc instead, but it&#039;s a real pain.  Just can&#039;t understand the logic of banning the RAND function from within a UDF!</description>
		<content:encoded><![CDATA[<p>This is a real pain.  I wanted to use RAND() in a UDF I was putting together to generate random URL keys and hit a brick wall with this.</p>
<p>I know there&#8217;s a few workarounds, such as having the RAND in a view, or just using a stored proc instead, but it&#8217;s a real pain.  Just can&#8217;t understand the logic of banning the RAND function from within a UDF!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Malar</title>
		<link>http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-44573</link>
		<dc:creator>Malar</dc:creator>
		<pubDate>Sat, 06 Dec 2008 12:28:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-44573</guid>
		<description>how to change only day part with the day what we want in the date?
for example,i need to compute the date(6-dec-08) which is having the day(&#039;6&#039; should be changed) part from a table.</description>
		<content:encoded><![CDATA[<p>how to change only day part with the day what we want in the date?<br />
for example,i need to compute the date(6-dec-08) which is having the day(&#8216;6&#8242; should be changed) part from a table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Function Property - Deterministic or Non-Deterministic Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-38293</link>
		<dc:creator>SQL SERVER - Function Property - Deterministic or Non-Deterministic Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Sat, 17 May 2008 09:39:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-38293</guid>
		<description>[...] SQL SERVER - 2005 - Use of Non-deterministic Function in UDF - Find Day Difference Between Any Date ...  You can run following code to determine if function is deterministic or not. [...]</description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; 2005 &#8211; Use of Non-deterministic Function in UDF &#8211; Find Day Difference Between Any Date &#8230;  You can run following code to determine if function is deterministic or not. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-34251</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Tue, 11 Mar 2008 14:31:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-34251</guid>
		<description>So in other words, we&#039;re not able to do things we should logically be able to do because of poor design in SQL Server&#039;s internals? Yes, heaven forbid a UDF use Rand(), and make subsequent calls to Rand() non-deterministic...

Someone as M$ is taking the whole &quot;no side-effects&quot; thing a bit too literally. At least this is a step in the right direction.</description>
		<content:encoded><![CDATA[<p>So in other words, we&#8217;re not able to do things we should logically be able to do because of poor design in SQL Server&#8217;s internals? Yes, heaven forbid a UDF use Rand(), and make subsequent calls to Rand() non-deterministic&#8230;</p>
<p>Someone as M$ is taking the whole &#8220;no side-effects&#8221; thing a bit too literally. At least this is a step in the right direction.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-9107</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Thu, 23 Aug 2007 19:06:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/23/sql-server-2005-use-of-non-deterministic-function-in-udf-find-day-difference-between-any-date-and-today/#comment-9107</guid>
		<description>SQL Server 2005 has allowed some of the non-deterministic functions that were not allowed in 2000.  In 2005 you can now use 
CURRENT_TIMESTAMP
@@MAX_CONNECTIONS
GET_TRANSMISSION_STATUS
@@PACK_RECEIVED
GETDATE
@@PACK_SENT
GETUTCDATE
@@PACKET_ERRORS
@@CONNECTIONS
@@TIMETICKS
@@CPU_BUSY
@@TOTAL_ERRORS
@@DBTS
@@TOTAL_READ
@@IDLE
@@TOTAL_WRITE and
@@IO_BUSY

You still cannot use
NEWID
RAND
NEWSEQUENTIALID and
TEXTPTR

I got that detail from SQL Server Magazine, and may have changed since publication, but the end result is - it is not a bug, you can use GETDATE() in functions, 

Here is more directly from the article

&quot;SQL Server 2005 Books Online (BOL) doesn&#039;t provide a reason for this change or the distinction between the functions that are and aren&#039;t allowed, but you&#039;ll notice that the functions you can&#039;t use have side effects. That is, the SQL Server 2005 non-deterministic functions that aren&#039;t allowed make internal changes in the database or the system and leave a mark (such as a change to an interval value) that they have been invoked. And UDFs aren&#039;t allowed to have side effects. For example, when SQL Server invokes the RAND function it changes an internal value that&#039;s used to calculate the seed for the next invocation of the function. This means that had SQL Server allowed you to invoke RAND within a UDF, the invocation of the UDF would have changed the result of subsequent invocations of RAND outside the UDF as well. For this reason, you can&#039;t use RAND in a UDF, even in SQL Server 2005.&quot;</description>
		<content:encoded><![CDATA[<p>SQL Server 2005 has allowed some of the non-deterministic functions that were not allowed in 2000.  In 2005 you can now use<br />
CURRENT_TIMESTAMP<br />
@@MAX_CONNECTIONS<br />
GET_TRANSMISSION_STATUS<br />
@@PACK_RECEIVED<br />
GETDATE<br />
@@PACK_SENT<br />
GETUTCDATE<br />
@@PACKET_ERRORS<br />
@@CONNECTIONS<br />
@@TIMETICKS<br />
@@CPU_BUSY<br />
@@TOTAL_ERRORS<br />
@@DBTS<br />
@@TOTAL_READ<br />
@@IDLE<br />
@@TOTAL_WRITE and<br />
@@IO_BUSY</p>
<p>You still cannot use<br />
NEWID<br />
RAND<br />
NEWSEQUENTIALID and<br />
TEXTPTR</p>
<p>I got that detail from SQL Server Magazine, and may have changed since publication, but the end result is &#8211; it is not a bug, you can use GETDATE() in functions, </p>
<p>Here is more directly from the article</p>
<p>&#8220;SQL Server 2005 Books Online (BOL) doesn&#8217;t provide a reason for this change or the distinction between the functions that are and aren&#8217;t allowed, but you&#8217;ll notice that the functions you can&#8217;t use have side effects. That is, the SQL Server 2005 non-deterministic functions that aren&#8217;t allowed make internal changes in the database or the system and leave a mark (such as a change to an interval value) that they have been invoked. And UDFs aren&#8217;t allowed to have side effects. For example, when SQL Server invokes the RAND function it changes an internal value that&#8217;s used to calculate the seed for the next invocation of the function. This means that had SQL Server allowed you to invoke RAND within a UDF, the invocation of the UDF would have changed the result of subsequent invocations of RAND outside the UDF as well. For this reason, you can&#8217;t use RAND in a UDF, even in SQL Server 2005.&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
