Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @genreCount int = (SELECT COUNT(*) FROM Genre)
- DECLARE @artistCount int = (SELECT COUNT(*) FROM Artist)
- ;WITH nums AS (
- SELECT TOP 1000 n = ROW_NUMBER() OVER(ORDER BY (SELECT NULL))
- FROM syscolumns s1, syscolumns s2
- )
- INSERT INTO Audio (CreatedAt, Title, Duration, [Url], [Year], GenreId, ArtistId)
- SELECT
- CreatedAt = SYSDATETIME(),
- Title = 'Song ' + FORMAT(n, '0000'),
- Duration = 100 + ABS(CHECKSUM(NewId())) % 300,
- [Url] = 'http://some.url.com/' + CAST(n as varchar(10)),
- [Year] = 1980 + ABS(CHECKSUM(NewId())) % 45,
- GenreId = ABS(CHECKSUM(NewId())) % @genreCount + 1,
- ArtistId = ABS(CHECKSUM(NewId())) % @artistCount + 1
- FROM nums
- --SELECT * FROM Audio ORDER BY Id
- --DELETE FROM Audio WHERE Id >= 15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement