how to do first in first out in SQL Server 2008
USE [TEST2]
GO
/****** Object: StoredProcedure [dbo].[usp_chartData8] Script Date: 05/24/2010 14:30:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[usp_chartData8]
As
begin
declare @rowcount as integer
declare @deletecount as integer
declare @Totalrows as integer
set @Totalrows=10
select @rowcount=count (*) from tblBarcode;
IF (@rowcount > @Totalrows)
begin
select @deletecount=@rowcount-@Totalrows
print @Totalrows
print @rowcount
print @deletecount
delete top (@deletecount) from tblBarcode
End
End
--select * from tblBarcode
--EXEC usp_chartData8
when i run this then only it shows 10 rows i want to update automatically from SCADA to SQL