I'm working on a database(school project). I need some testing for that database(SQL Server 2008 R2).
I'm trying to test its recovery. There for i'm building a stored procedure so that it takes long enough to crash my pc.
The problem is that the while loop that i'm using doenst seems to work.
Stored procedure:
USE [OnderzoekSQL]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Test_pro_opnemen]
-- Add the parameters for the stored procedure here
@bnummer int OUT,
@i int
AS
BEGIN
SET NOCOUNT ON;
WHILE(@i <= @@ROWCOUNT )
-- Insert statements for procedure here
SELECT TOP 1 @bnummer = accountnumber
FROM dbo.bank
ORDER BY saldo DESC
PRINT @bnummer
UPDATE bank
SET saldo = '0'
WHERE accountnumber = @bnummer
SET @i = @i+1
END
And the table:
CREATE TABLE [dbo].[bank](
[accountnumber] [nvarchar](50) NOT NULL,
[saldo] [real] NULL,
[owner_id] [int] NULL;
And about the difference between the nvarchar and the int of accountnumber. It doesnt really matter because i only use number in accountnumber.
The procedure work if i remove the While loop