Function in SQL...................

Unknown | 6:35 AM |


USE [Surgere1]
GO
/****** Object:  UserDefinedFunction [dbo].[checkclassid]    Script Date: 04/27/2012 12:08:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[checkclassid] (@class_id bigint)
RETURNS @tblResult Table
 (
  class_id bigint
 )
AS
BEGIN
 if exists(select class_id from container where class_id=@class_id  )
  Begin
  Insert into @tblResult
  select class_id from container where class_id=@class_id
  End
  if exists(select class_id from subclass where class_id=@class_id )
  Begin
  Insert into @tblResult
  select class_id from subclass where class_id=@class_id
 END

 
  Return
END

Insert ,Update and return id in One Stored Procedure...........................

USE [Surgere1]
GO
/****** Object:  StoredProcedure [dbo].[dbo.facility_lane_addUpdate]    Script Date: 04/27/2012 12:05:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[dbo.facility_lane_addUpdate]
(
        @facility_lane_ID  bigint output  ,
        @facility_ID  bigint =NULL ,
        @door_no  varchar (20)  =NULL ,
        @door_name  varchar (50)  =NULL ,
        @door_order  bigint =NULL ,
        @IPReader  varchar (50)  =NULL ,
        @Created_id  bigint =NULL ,
        @Created_dt  datetime =NULL ,
        @Update_ID  bigint =NULL ,
        @Update_dt  datetime =NULL

)
AS
Begin
SET NOCOUNT ON;
             If @facility_lane_ID<1
             Begin
                   Insert into dbo.facility_lane
                   (
                                         facility_ID ,
                                         door_no ,
                                         door_name ,
                                         door_order ,
                                         IPReader ,
                                         Created_id ,
                                         Created_dt ,
                                         Update_ID ,
                                         Update_dt

                   )
                   Values
                   (
                                         @facility_ID ,
                                         @door_no ,
                                         @door_name ,
                                         @door_order ,
                                         @IPReader ,
                                         @Created_id ,
                                         @Created_dt ,
                                         @Update_ID ,
                                         @Update_dt

                   );
Set @facility_lane_ID=SCOPE_IDENTITY();
                    END
                     Else
                    BEGIN
Update dbo.facility_lane
set
                                         facility_ID = @facility_ID ,
                                         door_no = @door_no ,
                                         door_name = @door_name ,
                                         door_order = @door_order ,
                                         IPReader = @IPReader ,
                                         Created_id = @Created_id ,
                                         Created_dt = @Created_dt ,
                                         Update_ID = @Update_ID ,
                                         Update_dt = @Update_dt

Where facility_lane_ID=@facility_lane_ID;
            END
Return @facility_lane_ID
END

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....