Created
October 21, 2015 12:31
-
-
Save MarshalOfficial/0fe8342ea589f7f08927 to your computer and use it in GitHub Desktop.
this script generate random data as output (random varchar,random datetime,random numeric)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET NOCOUNT ON | |
GO | |
CREATE TABLE #RandomData ( | |
RowId INT IDENTITY(1,1) NOT NULL, | |
SomeVarchar VARCHAR(10), | |
SomeDateTime DATETIME, | |
SomeNumeric NUMERIC(16,2) ) | |
GO | |
DECLARE @count INT | |
SET @count = 1 | |
WHILE @count <= 50 | |
BEGIN | |
INSERT INTO #RandomData (SomeVarchar,SomeDateTime,SomeNumeric) | |
SELECT | |
CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + | |
CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + | |
CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + | |
CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + | |
CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) + CHAR((ABS(CHECKSUM(NEWID())) % 26) + 97) [SomeVarchar], | |
DATEADD(MILLISECOND, (ABS(CHECKSUM(NEWID())) % 6000) * -1, | |
DATEADD(MINUTE, (ABS(CHECKSUM(NEWID())) % 1000000) * -1, GETDATE())) [SomeDateTime], | |
(ABS(CHECKSUM(NEWID())) % 100001) + ((ABS(CHECKSUM(NEWID())) % 100001) * 0.00001) [SomeNumeric] | |
SET @count += 1 | |
END | |
SELECT * FROM #RandomData | |
DROP TABLE #RandomData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment