Does anyone know what i'm doing wrong here, I have a webpage that gets currency data from a remote source, I get the data and insert it into sql database via a stored procedure. If i put truncate in front of the insert statement, it truncates the table and inserts the last record. If i remove the truncate, it inserts all the records.
i.e
truncate table tblTablename;
insert into tblTablename
(columns)
values
(data)
The above will insert the last record from 289 records.
If i remove truncate all 289 records are inserted.
I have tried using waitfor, for 1 second but that failed to work either.
I'm not sure what else to do, so any help would be appreciated
In webpage I have a foreach loop
George
/---------------------- SQL Code -----------------
ALTER PROCEDURE [dbo].[atSP_InsertCurrency]
-- Add the parameters for the stored procedure here
@CurrencyCountry VarChar(150),
@CurrencyRate VarChar(150),
@UpdateSuccessFail INT OUTPUT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
TRUNCATE TABLE [dbo].[at_CurrencyRates];
WAITFOR DELAY '000:00:01'
INSERT INTO [dbo].[at_CurrencyRates]
(
[CurrencyCode],
[CurrencyExchangeRate]
)
VALUES
(
@CurrencyCountry,
@CurrencyRate
)
IF(@@ROWCOUNT > 0)
BEGIN
select @UpdateSuccessFail = '1'
END
ELSE
BEGIN
select @UpdateSuccessFail = '0'
END
END