I\'m a newbie to SQL Server. Please help me to write the following Logic in a query.
If getnow() > today 4 PM Then SELECT * FROM table WHERE M
IF DATEPART(HOUR, GETDATE()) > 16 BEGIN -- SELECT statement END ELSE BEGIN -- SELECT statement END
It does not have to be in a stored procedure.
You need a stored procedure to do this in SQL. Have a look at the docs here http://msdn.microsoft.com/en-us/library/aa174792(v=sql.80).aspx