Advertisement
otkalce

Create random audio data

May 15th, 2024
1,386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.72 KB | Software | 0 0
  1. DECLARE @genreCount int = (SELECT COUNT(*) FROM Genre)
  2. DECLARE @artistCount int = (SELECT COUNT(*) FROM Artist)
  3.  
  4. ;WITH nums AS (
  5.     SELECT TOP 1000 n = ROW_NUMBER() OVER(ORDER BY (SELECT NULL))
  6.     FROM syscolumns s1, syscolumns s2
  7. )
  8. INSERT INTO Audio (CreatedAt, Title, Duration, [Url], [Year], GenreId, ArtistId)
  9. SELECT
  10.     CreatedAt = SYSDATETIME(),
  11.     Title = 'Song ' + FORMAT(n, '0000'),
  12.     Duration = 100 + ABS(CHECKSUM(NewId())) % 300,
  13.     [Url] = 'http://some.url.com/' + CAST(n as varchar(10)),
  14.     [Year] = 1980 + ABS(CHECKSUM(NewId())) % 45,
  15.     GenreId = ABS(CHECKSUM(NewId())) % @genreCount + 1,
  16.     ArtistId = ABS(CHECKSUM(NewId())) % @artistCount + 1
  17. FROM nums
  18.  
  19. --SELECT * FROM Audio ORDER BY Id
  20. --DELETE FROM Audio WHERE Id >= 15
Tags: random
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement