none
using SQL stored functions RRS feed

  • Question

  •  

    Is it possible to use an SQL user defined function in a DataSet and if so, how?  This is not a CLR function, this is a SQL function

     

    ALTER FUNCTION dbo.ItemExists

    (

    @Item varchar(50)

    /*

    @parameter1 int = 5,

    @parameter2 datatype

    */

    )

    RETURNS bit /* datatype */

    AS

    BEGIN

    DECLARE @Result int

    SET @Result = (SELECT COUNT(*) AS Expr1

    FROM Items

    WHERE (Item = @Item));

    DECLARE @Test bit

    if (@Result > 0)

    SET @Test = 1

    else

    SET @Test = 0

    RETURN (@Test) /* value */

    END

    Wednesday, October 24, 2007 12:07 PM

All replies

  • You can call it using the same methods as you would a stored procedure, if that is what you are asking. Otherwise I'm not sure in what other context you expect to use it.

     

    Wednesday, October 24, 2007 1:01 PM
  •  

    Maybe on a more complete version of Visual Studio, but I am using the Standard Edition and I do not get the results that I would expect.
    Sunday, October 28, 2007 5:17 PM