Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have following function in sql server. how to use this function in front end.basically this function is for city already exist or no.so,plz help me?

SQL
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER FUNCTION [QAPower].[CITY_ALREADY_EXISTS] (@CITY_DESC VARCHAR(MAX),@RECORD_TYPE BIT,@COUNTRY_ID TINYINT,@CITY_ID TINYINT)

RETURNS BIT

AS
BEGIN
    DECLARE  @RESULT TINYINT

         IF(@RECORD_TYPE=0)
          SET @RESULT=(SELECT COUNT (*) FROM QAPower.HDR_CITY WHERE CITY_DESC=@CITY_DESC AND COUNTRY_ID=@COUNTRY_ID)
        ELSE
          SET @RESULT=(SELECT COUNT (*) FROM QAPower.HDR_CITY WHERE CITY_DESC=@CITY_DESC AND  NOT (COUNTRY_ID=@COUNTRY_ID AND CITY_ID=@CITY_ID))

    IF (@RESULT) > 0
        RETURN 1
    ELSE
       RETURN  0

    RETURN 1
END
Posted

Refer:
SQL Server user-defined function[^]
how to use UDF's with asp.net[^]

..and get more simlar threads here[^].
 
Share this answer
 
Hi,

See the below link. It might be help you to get idea how to call function in c#.

http://stackoverflow.com/questions/3013192/calling-sql-functions-directly-from-c-sharp[^]

Thanks,
Viprat
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900