Q:

Delete 75% Of a Table Randomly

Trying to make a smaller sample database but still have the data be somewhat statistically relevant.  How can I delete x % of rows from the table ?  Been fooling around with the NEWID() function.

A:

DELETE 
FROM TABLE_NAME
WHERE PK IN (SELECT TOP (75) PRECENT PK
             FROM TABLE_NAME
             ORDER BY NEWID())

Suggestion by Martin Smith
DELETE T 
FROM (SELECT TOP (75) PERCENT * 
      FROM TABLE_NAME 
      ORDER BY NEWID()) T

A:

Another way would be:
DELETE 
FROM table_name
WHERE ABS(CHECKSUM(NEWID())) % 100 < 75 ;

It will not delete exactly 75% of the rows but it will be faster for a bigger table, as it won't need to do a sort.

