|
|
-
58 Liked
| 55 Learned
| 18 Comments
|
|
Suppose you have three tables named test1,test2 and test3 and you want to drop all these three, you can do it in a single DROP statement
[code]DROP table test1,test2,test3[/code]......
|
|
-
49 Liked
| 46 Learned
| 31 Comments
|
|
Suppose you have a huge table which has say 30-40 columns and you want to select all of them or most of them say around 30 columns. It is a tedious job to type each of the column names. Here is a quick way to get a comma separated list of all the column......
|
|
-
44 Liked
| 42 Learned
| 11 Comments
|
|
The IN clause in T-SQL can be used to find a single value present in any one of multiple supplied columns. For example, in the AdventureWorks database:
[code]
SELECT Title, FirstName, MiddleName, LastName, Suffix
FROM Person.Contact
WHERE 'Lee' I......
|
|
-
37 Liked
| 26 Learned
| 5 Comments
|
|
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 'i......
|
|
-
27 Liked
| 22 Learned
| 5 Comments
|
|
While you are working in Query window, if you want to delete the current row, you have to highlight entire row and press delete key. Another alternate is to use SHIFT+DEL key. The cursor can be at any position and the entire row will be deleted......
|
|
-
25 Liked
| 27 Learned
| 3 Comments
|
|
I have been working on creating my demo scripts for "Tech-ED India 2012" and while trying different options, realized that the FORMAT function can be (mis)used to embed external strings into the format specification.
PRINT FORMAT( GETDATE(), '"-...
|
|
-
23 Liked
| 21 Learned
| 3 Comments
|
|
How do I know which deprecated features I’m using?
To find out, run the following query:
[code]
SELECT instance_name AS 'Deprecated Feature', cntr_value AS 'Times Used'
FROM sys.dm_os_performance_counters
WHERE object_name = 'SQLServer:Deprecated F......
|
|
-
|
|
Sometimes while writing a query, we might have the requirement of dynamic sorting, i.e. sorting based on different column based on certain conditions.
To do this often developers will use dynamic queries. Without resorting to Dynamic queries, we can w......
|
|
-
23 Liked
| 16 Learned
| 4 Comments
|
|
We had a contract dba who was asked to create a database.From outside look the database looked normal, but for some reason code would not recognize it and we kept getting error that database does not exist or user does not have permissions. We tried put......
|
|
-
22 Liked
| 9 Learned
| 12 Comments
|
|
From a disconnected query window, we can connect back to the SQL Server instance from the **Query > Connection > Connect** menu option. This may sound simple, but I found this interesting.
I usually press F5 (or execute button) twice to get connected a...
|
|