SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
_WOW_2 snippet for generating table wrapper procs (MSSQL)

 
Reply to topic    SoftTree Technologies Forum Index » Tips & Snippets Repository View previous topic
View next topic
_WOW_2 snippet for generating table wrapper procs (MSSQL)
Author Message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6499

Post _WOW_2 snippet for generating table wrapper procs (MSSQL) Reply with quote
Code:
USE [$DB$]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
--    Created By: $OSUSER$
--  Created Date: $DATE$ $TIME$
--   Description: Update procedure for table $OBJECT$
--                Table primary key must be an identity column
--
--   Modified By:
-- Modified Date:
--      Comments:
-- =============================================
CREATE PROCEDURE [dbo].[usp$OBJECT$_Update_By$COLUMN_KEYS$]
(
   @$COLUMNS+TYPES_V$=NULL
)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
   SET NOCOUNT ON;

   IF @$COLUMN_KEYS_V$ < 1
      BEGIN
         INSERT INTO $OBJECT$
         (
            $COLUMNS_V$
         )
         VALUES
         (
            @$COLUMNS_V$
         )
         SELECT SCOPE_IDENTITY() $COLUMN_KEYS_V$
      END
   ELSE
      BEGIN
         UPDATE $OBJECT$ SET
            $COLUMNS_V$ = @$COLUMNS_V$
         WHERE $COLUMN_KEYS_V$ = @$COLUMN_KEYS_V$

         SELECT @$COLUMN_KEYS_V$ $COLUMN_KEYS_V$
      END
END

Fri Jul 01, 2011 12:43 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » Tips & Snippets Repository All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.