Sort randomly
To sort radomly every time you run the query, use this method,
SELECT columnname1, columnname2 FROM YOURTABLE ORDER BY NEWID()
To sort radomly every time you run the query, use this method,
SELECT columnname1, columnname2 FROM YOURTABLE ORDER BY NEWID()
Posted by
Guru Prasath
at
11:55 pm
0
comments
To find the days in a month using SQL, use the following method. Here TSQL syntax is used for example.
--------------------
DECLARE @Date datetime
SET @Date = '2000/02/1'
SELECT DATEADD(dd,-(DATEPART(dw, @Date) - 1),@Date) AS 'First day of the week'
SELECT DATEADD(dd,-(DATEPART(dw, @Date) - 7),@Date) AS 'Last day of the week'
SELECT DAY(DATEADD(d, -DAY(DATEADD(m,1,@Date)),DATEADD(m,1,@Date))) AS 'Last day of the month'
--------------------
for more sql tricks goto.. Extremeexperts
Posted by
Guru Prasath
at
8:29 pm
6
comments