Thanks to all of you, I am now able to write c sharp applications, stored procedures in SQL Server etc etc...
One thing I failed to search in web is that I want to generate blank records ( a record for each cheque in my cheque book) that would require a for next look in a stored procedure, I will give starting cheque number and the quantity of checks in the check book....the stored procedure should generate blank record for each cheque...
Can you please help in rectifying my stored procedure code (given below):
USE [CHQ]
GO
/****** Object: StoredProcedure [dbo].[CHQ_Insert_Genrate_New_ChqBook] Script Date: 5/14/2018 11:44:52 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[CHQ_Insert_Genrate_New_ChqBook]
@MyCounter int,
@BankCode nvarchar(100),
@ChequeNo float,
@QtyOfChq int
AS
BEGIN
SET @MyCounter = 1 -- to use this multiple times you can just
-- change the starting number and run again
-- if you do not want duplicate numbers
WHILE @MyCounter < @QtyOfChq -- any value you want
set @ChequeNo = @ChequeNo + @MyCounter - 1
BEGIN
INSERT INTO dbo.CHQPayments([Cheque No],BankCode)
VALUES
(@ChequeNo,@BankCode) -- insert counter value into table
set @MyCounter = @MyCounter + 1
END
End
Its not returning any error message...but it keeps on running without any result...
The values as displayed in sql text are:
USE [CHQ]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[CHQ_Insert_Genrate_New_ChqBook]
@MyCounter = 1,
@BankCode = N'BBB-FR-347123456789',
@ChequeNo = 1000001,
@QtyOfChq = 10
SELECT 'Return Value' = @return_value
GO