Skip to content

Instantly share code, notes, and snippets.

@mariochavez
Created August 9, 2010 07:40
Show Gist options
  • Select an option

  • Save mariochavez/515098 to your computer and use it in GitHub Desktop.

Select an option

Save mariochavez/515098 to your computer and use it in GitHub Desktop.
USE [Codigos]
GO
/****** Object: StoredProcedure [dbo].[InsClient] Script Date: 08/09/2010 00:39:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object: Stored Procedure dbo.InsClient Script Date: 4/28/2010 9:47:01 AM ******/
ALTER PROCEDURE [dbo].[InsClient]
(
@Code varchar(10),
@Name varchar(300),
@Rfc varchar(20),
@DataExchangeId uniqueidentifier,
@eInvoice bit,
@Enable bit,
@CreatedBy int,
@CreatedOn datetime
)
AS
DECLARE @Count int
SELECT @Count = COUNT(Id)
FROM Client WHERE Code = @Code
IF @Count > 0
BEGIN
RAISERROR('Client %s already exists', 16, 1, @Code)
RETURN 1
END
INSERT INTO Client(Code, Name, Rfc, DataExchangeId, eInvoice, Enable, CreatedBy, CreatedOn)
VALUES(@Code, @Name, @Rfc, @DataExchangeId, @eInvoice, @Enable, @CreatedBy, @CreatedOn)
SELECT * FROM Client WHERE Id = @@Identity
RETURN
GO
USE [Codigos]
GO
/****** Object: StoredProcedure [dbo].[UpdClient] Script Date: 08/09/2010 00:40:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object: Stored Procedure dbo.UpdClient Script Date: 4/28/2010 9:47:01 AM ******/
ALTER PROCEDURE [dbo].[UpdClient]
(
@Id int,
@Name varchar(300),
@Rfc varchar(20),
@DataExchangeId uniqueidentifier,
@eInvoice bit,
@Enable bit,
@UpdatedBy int,
@UpdatedOn datetime
)
AS
UPDATE Client SET Name = @Name, Rfc = @Rfc,
DataExchangeId = @DataExchangeId, Enable = @Enable,
eInvoice = @eInvoice,
UpdatedBy = @UpdatedBy, UpdatedOn = @UpdatedOn
WHERE Id = @Id;
SELECT * FROM Client WHERE Id = @Id
RETURN
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment