SQL

Retrieving Random Rows

You can run script below and it will give random rows every single time you run it:   USE AdventureWorks2012 GO -- Method 1 SELECT TOP 100* FROM SalesOrderDetail ORDER BY NEWID() GO -- Method 2 SELECT TOP 100 * FROM SalesOrderDetail ORDER BY...

Read More

Removing Leading Zeros

Removing Leading Zeros From Column in Table   USE tempdb GO -- Create sample table CREATE TABLE Table1 (Col1 VARCHAR(100)) INSERT INTO Table1 (Col1) SELECT '000006' UNION ALL SELECT '00501007' UNION ALL SELECT '50401003' UNION ALL SELECT '0100 000 001' UNION ALL SELECT '00.0001' UNION ALL SELECT '07.001' GO -- Display the data from the new table SELECT * FROM Table1 GO -- Remove leading...

Read More