|
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
During working for script to send mail alerts, i just learned as we can change display name for the mail at runtime. It will normally use profile name or display name which configured in database mail profile for mail. Below query will use display name "Ma
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
Just learned from pinal's blog that by using SSMS, we can generate various reports also. Suppose, we can generate the report of top queries by average CPU Time or average IO Time etc.
In SSMS, Right click on server name-> Reports -> Standard Repor
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
i just learned today, one new thing , "how to find index fragmentation details of all tables in database with using system function sys.dm_db_index_physical_stats." Check out following query.
[code]
Select object_name(a.object_id) AS Table_Name,
b
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
In past, during working with table partitioning I learned that we can also apply different types of compressions for different partitions of a partitioned table. Below are the queries which rebuild partitions with different page and row compressions.
[C
|
-
Ashish Gilhotra Posted 2 Years ago through Just Learned | 5 Points
If we have a requirement like we need to get the top 2 employees basis on the department name which is having high performance without using any kind of RANKING functions than we can achieve this by following query.
DECLARE @top INT
SET @top=1
SELEC
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
Always we will start identity value from 1 and increment by 1. However, an identity column can have negative seed value and can be negatively also incremented.
Suppose below table will have 4 rows with id values -100,-101,-102,-103
[code]
declare @t ta
|
-
Ashish Gilhotra Posted 2 Years ago through Just Learned | 5 Points
In previous version of SQL Server if we need to find the last date of the month, then we have to do something like this.
SELECT DATEADD(DD,0,DATEDIFF(DD,0,DATEADD(dd, -DAY(DATEADD(m,1,GETDATE())), DATEADD(m,1,GETDATE()))))
This will give us below out
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
TRY_CONVERT() returns a value to be cast to the specified data type if the cast succeeds; otherwise, returns null.
It has require three arguments, first is data_type(length) in which value cast, second is exprssion value and third is style which is option
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
I just reviewed one more datetime enhanced feature provided by SQL Server 2011 CTP3 and it is FORMAT. It will return formatted value of specific format with DATETIME in query.
It has three arguments, first argument is for the datetime, second is for forma
|
-
Ashish Gilhotra Liked 2 Years ago through Just Learned | 1 Point
What if you want to find out if a specific field contains a certain value?
For example you want to find out all employees who have 0 vacation hours and 0 sickhours.
Common way is to write a where clause with 'or'.
Another way to do this is to use 'in'
|