Wednesday, September 28, 2011

SQL Server Tips

1. How to extract Date part from Date Time ?

You will come across situation to extract DateFrom SQL Server DateTime field. So, here is the way.
select dateadd(D,0,datediff(D,0,GETDATE()))


2.  How to find references to a string from all Stored Procedures
 
SELECT so.name ProcedureName, TEXT

, so.create_date [Created Date]
, so.modify_date [Modified Date]
FROM SysComments sc
JOIN Sys.Objects so ON OBJECT_NAME(sc.id) = so.name
WHERE Text LIKE '%Sample%'

No comments: