Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SeveralRows -table
- IF OBJECT_ID ( 'TestData', 'U' ) IS NOT NULL
- DROP TABLE TestData;
- GO
- -- Create the table
- CREATE TABLE TestData (
- Id int NOT NULL IDENTITY(1,1)PRIMARY KEY,
- InsertTime time NOT NULL DEFAULT (GETDATE()),
- Category int NOT NULL
- );
- GO
- SET NOCOUNT ON
- DECLARE @max int;
- DECLARE @counter int;
- DECLARE @rand_number int;
- SET @max = 10;
- BEGIN
- SET @counter = 0;
- WHILE @counter < @max BEGIN
- SET @rand_number = RAND() * 10000;
- INSERT INTO TestData (Category)
- VALUES (CONVERT(varchar, @rand_number));
- SET @counter = @counter + 1;
- END;
- END;
- GO
- SELECT * FROM TestData
Advertisement
Add Comment
Please, Sign In to add comment