﻿<?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)  / Throw an error/exception from a function / 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>Tue, 18 Jun 2013 00:27:18 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Throw an error/exception from a function</title><link>http://www.sqlservercentral.com/Forums/Topic436078-338-1.aspx</link><description>Just do a SELECT 1/0.... trust me, it'll throw an error ;)</description><pubDate>Sun, 23 Dec 2007 23:30:50 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Throw an error/exception from a function</title><link>http://www.sqlservercentral.com/Forums/Topic436078-338-1.aspx</link><description>Hi,Functions are best suited for my requirement. I use the value returned by a scalar user defined function as a part of insert into t1 select *, function_f1() from t2.i cannot use a stored procedure here. however, there is a business validation that I want to do inside the function for which I will have to throw an exception / error. Please let me know if there is any method to do this or any work around for this...Thanks,Roopa.</description><pubDate>Sun, 23 Dec 2007 22:50:51 GMT</pubDate><dc:creator>Roopa Prabhu</dc:creator></item><item><title>RE: Throw an error/exception from a function</title><link>http://www.sqlservercentral.com/Forums/Topic436078-338-1.aspx</link><description>RoopaYou cannot use the standard RAISERROR statement in a function nor can u use the TRY...CATCH construct to throw a error. How ever you can catch any error in the application that calls your function. In case you want to return a exeception for some validation purpose then you can set a pre-defined value to a variable and return that.Just curious.. do you really require a function or can u use a procedure for your needs.</description><pubDate>Sun, 23 Dec 2007 22:30:45 GMT</pubDate><dc:creator>ChiragNS</dc:creator></item><item><title>Throw an error/exception from a function</title><link>http://www.sqlservercentral.com/Forums/Topic436078-338-1.aspx</link><description>Hi all,Is it possible for me to throw an exception/error from a function in sql server 2005? if yes, then please let me know the syntax for it.Thanks,Roopa.</description><pubDate>Sun, 23 Dec 2007 21:23:43 GMT</pubDate><dc:creator>Roopa Prabhu</dc:creator></item></channel></rss>