<?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; Introduction to Function SIGN</title>
	<atom:link href="http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 23 May 2013 14:22:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: tejas</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-420525</link>
		<dc:creator><![CDATA[tejas]]></dc:creator>
		<pubDate>Mon, 11 Feb 2013 07:53:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-420525</guid>
		<description><![CDATA[SUM( DECODE( SIGN(DAYDIFF(TransactionReceivableDetail.Receivable.AssignedPayment.CreatedOn,TempAttributesRescission.RescissionPaymentAsofDate)),1,0,TransactionReceivableDetail.Receivable.AssignedPayment.PaymentAmount))

this query is returning a null value can u explain]]></description>
		<content:encoded><![CDATA[<p>SUM( DECODE( SIGN(DAYDIFF(TransactionReceivableDetail.Receivable.AssignedPayment.CreatedOn,TempAttributesRescission.RescissionPaymentAsofDate)),1,0,TransactionReceivableDetail.Receivable.AssignedPayment.PaymentAmount))</p>
<p>this query is returning a null value can u explain</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Low</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-389746</link>
		<dc:creator><![CDATA[Eric Low]]></dc:creator>
		<pubDate>Sat, 08 Dec 2012 17:43:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-389746</guid>
		<description><![CDATA[Hi! This is SQL statement found in SQL Profiler..

SELECT SUM(amount_book * -SIGN(cleared_type -0.5)) FROM cminpdtl WHERE date_applied &lt;=  734760  AND cash_acct_code =  &#039;15080202ADMNHQIP002&#039;

May I know what is the use of -SIGN(fieldname -0.5)?
Why must use -0.5 and not just the fieldname will do? cleared_type is just a value either 0 or 1.

Thank you very much in advance!]]></description>
		<content:encoded><![CDATA[<p>Hi! This is SQL statement found in SQL Profiler..</p>
<p>SELECT SUM(amount_book * -SIGN(cleared_type -0.5)) FROM cminpdtl WHERE date_applied &lt;=  734760  AND cash_acct_code =  &#039;15080202ADMNHQIP002&#039;</p>
<p>May I know what is the use of -SIGN(fieldname -0.5)?<br />
Why must use -0.5 and not just the fieldname will do? cleared_type is just a value either 0 or 1.</p>
<p>Thank you very much in advance!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-306929</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Thu, 28 Jun 2012 11:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-306929</guid>
		<description><![CDATA[Looks excellent!]]></description>
		<content:encoded><![CDATA[<p>Looks excellent!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spyder</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-306909</link>
		<dc:creator><![CDATA[Spyder]]></dc:creator>
		<pubDate>Thu, 28 Jun 2012 10:25:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-306909</guid>
		<description><![CDATA[Brilliant.

I have to run a report where all values must be positive.  Now, instead of:

UPDATE MyTable
      SET Amount =
            CASE
                  WHEN Amount &lt; 0 THEN
                        (Amount * -1) * Currency
                  ELSE
                        Amount * Currency
                  END

I can use:

UPDATE MyTable
      SET Amount = (Amount * SIGN(Amount)) * Currency

Seems to run quicker too.  Any comment on that?]]></description>
		<content:encoded><![CDATA[<p>Brilliant.</p>
<p>I have to run a report where all values must be positive.  Now, instead of:</p>
<p>UPDATE MyTable<br />
      SET Amount =<br />
            CASE<br />
                  WHEN Amount &lt; 0 THEN<br />
                        (Amount * -1) * Currency<br />
                  ELSE<br />
                        Amount * Currency<br />
                  END</p>
<p>I can use:</p>
<p>UPDATE MyTable<br />
      SET Amount = (Amount * SIGN(Amount)) * Currency</p>
<p>Seems to run quicker too.  Any comment on that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-306346</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Wed, 27 Jun 2012 07:11:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-306346</guid>
		<description><![CDATA[Excellent suggestion - I totally agree with it!]]></description>
		<content:encoded><![CDATA[<p>Excellent suggestion &#8211; I totally agree with it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-306345</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Wed, 27 Jun 2012 07:11:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-306345</guid>
		<description><![CDATA[Hi,

In that case you can just multiply the value with -1.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>In that case you can just multiply the value with -1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: guillegr123</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-306088</link>
		<dc:creator><![CDATA[guillegr123]]></dc:creator>
		<pubDate>Tue, 26 Jun 2012 14:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-306088</guid>
		<description><![CDATA[There is a kind of &quot;inverse&quot; function of the SIGN function? For example, if the value is a positive number, it returns -1, and if it is a negative number, it returns 1.]]></description>
		<content:encoded><![CDATA[<p>There is a kind of &#8220;inverse&#8221; function of the SIGN function? For example, if the value is a positive number, it returns -1, and if it is a negative number, it returns 1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305906</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Tue, 26 Jun 2012 05:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305906</guid>
		<description><![CDATA[I re-ran the query and new image is now uploaded. Thanks for your attention to the details.]]></description>
		<content:encoded><![CDATA[<p>I re-ran the query and new image is now uploaded. Thanks for your attention to the details.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vincyf1</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305903</link>
		<dc:creator><![CDATA[vincyf1]]></dc:creator>
		<pubDate>Tue, 26 Jun 2012 05:07:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305903</guid>
		<description><![CDATA[My I suggest another correction: NumVal3 value in the screenshot should be 0.00 :)]]></description>
		<content:encoded><![CDATA[<p>My I suggest another correction: NumVal3 value in the screenshot should be 0.00 :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vincyf1</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305900</link>
		<dc:creator><![CDATA[vincyf1]]></dc:creator>
		<pubDate>Tue, 26 Jun 2012 05:05:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305900</guid>
		<description><![CDATA[Result for NumVal3 should be 0.00 in the screenshot :)]]></description>
		<content:encoded><![CDATA[<p>Result for NumVal3 should be 0.00 in the screenshot :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kumar Harsh</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305472</link>
		<dc:creator><![CDATA[Kumar Harsh]]></dc:creator>
		<pubDate>Mon, 25 Jun 2012 05:10:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305472</guid>
		<description><![CDATA[Sign can also be use in 
i)When we have to find if table contain any rowcount or not.
  Select sign(@@rowcount)
Select sign(count(*) from emp 
ii) IsNullOrEmpty(equivalent function of c#)

CREATE FUNCTION dbo.IsNullOrEmpty(@text NVARCHAR(4000))
RETURNS BIT
AS
BEGIN

     return SIGN(LEN(isnull(@text,&#039;&#039;)))

END

GO]]></description>
		<content:encoded><![CDATA[<p>Sign can also be use in<br />
i)When we have to find if table contain any rowcount or not.<br />
  Select sign(@@rowcount)<br />
Select sign(count(*) from emp<br />
ii) IsNullOrEmpty(equivalent function of c#)</p>
<p>CREATE FUNCTION dbo.IsNullOrEmpty(@text NVARCHAR(4000))<br />
RETURNS BIT<br />
AS<br />
BEGIN</p>
<p>     return SIGN(LEN(isnull(@text,&#8221;)))</p>
<p>END</p>
<p>GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305425</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Mon, 25 Jun 2012 03:04:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305425</guid>
		<description><![CDATA[Fixed the typo thank you so much My friend!]]></description>
		<content:encoded><![CDATA[<p>Fixed the typo thank you so much My friend!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305424</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Mon, 25 Jun 2012 03:03:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305424</guid>
		<description><![CDATA[Fixed the typo thank you so much!]]></description>
		<content:encoded><![CDATA[<p>Fixed the typo thank you so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kk</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305376</link>
		<dc:creator><![CDATA[kk]]></dc:creator>
		<pubDate>Mon, 25 Jun 2012 01:11:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305376</guid>
		<description><![CDATA[Thanks for writing about this function. I have learnt a new function. But seems you have a typo in the second SELECT statement:
SIGN(@NumVal2) NumVal3 =&gt; SIGN(@NumVal3) NumVal3]]></description>
		<content:encoded><![CDATA[<p>Thanks for writing about this function. I have learnt a new function. But seems you have a typo in the second SELECT statement:<br />
SIGN(@NumVal2) NumVal3 =&gt; SIGN(@NumVal3) NumVal3</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Emerick</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-305238</link>
		<dc:creator><![CDATA[Michael Emerick]]></dc:creator>
		<pubDate>Sun, 24 Jun 2012 16:41:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-305238</guid>
		<description><![CDATA[Think you might have a small typo, though the results you have portrayed are correct.

This:
SELECT SIGN(@NumVal1) NumVal1,SIGN(@NumVal2) NumVal2,SIGN(@NumVal2) NumVal3

Should be:
SELECT SIGN(@NumVal1) NumVal1,SIGN(@NumVal2) NumVal2,SIGN(@NumVal3) NumVal3

As always thanks so much for all of your posts, they have helped me come a long way!]]></description>
		<content:encoded><![CDATA[<p>Think you might have a small typo, though the results you have portrayed are correct.</p>
<p>This:<br />
SELECT SIGN(@NumVal1) NumVal1,SIGN(@NumVal2) NumVal2,SIGN(@NumVal2) NumVal3</p>
<p>Should be:<br />
SELECT SIGN(@NumVal1) NumVal1,SIGN(@NumVal2) NumVal2,SIGN(@NumVal3) NumVal3</p>
<p>As always thanks so much for all of your posts, they have helped me come a long way!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DHall</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-304622</link>
		<dc:creator><![CDATA[DHall]]></dc:creator>
		<pubDate>Sat, 23 Jun 2012 05:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-304622</guid>
		<description><![CDATA[Sign() can also be used it calculate an equivalent alternative to the ABS() function. Note that the last two columns have the same values.:

USE tempdb
CREATE TABLE T ( N INT )
INSERT INTO T VALUES ( -42), (-11), (0), (NULL), (17), (2)
SELECT N, 
        N * SIGN(N) AS NxSignN, 
        ABS(N) AS AbsN 
FROM T
DROP TABLE T
GO]]></description>
		<content:encoded><![CDATA[<p>Sign() can also be used it calculate an equivalent alternative to the ABS() function. Note that the last two columns have the same values.:</p>
<p>USE tempdb<br />
CREATE TABLE T ( N INT )<br />
INSERT INTO T VALUES ( -42), (-11), (0), (NULL), (17), (2)<br />
SELECT N,<br />
        N * SIGN(N) AS NxSignN,<br />
        ABS(N) AS AbsN<br />
FROM T<br />
DROP TABLE T<br />
GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jay</title>
		<link>http://blog.sqlauthority.com/2012/06/23/sql-server-introduction-to-function-sign/#comment-304588</link>
		<dc:creator><![CDATA[jay]]></dc:creator>
		<pubDate>Sat, 23 Jun 2012 02:57:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19522#comment-304588</guid>
		<description><![CDATA[Excellent post. It&#039;s impressive how SIGN allows one to write much less code to get the same output.]]></description>
		<content:encoded><![CDATA[<p>Excellent post. It&#8217;s impressive how SIGN allows one to write much less code to get the same output.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
