|
|
-
|
|
I often see that some junior develepers forget an important thing while designing a table. They choose wrong datatypes to store data ie VARCHAR to store DATETIME or DECIMAL values. This is mostly identified either when verifying the design or giving som...
|
|
-
|
|
Without executing this query, can you find out the output?
select _________ name from
(
select 2e4 _________
) t
...
|
|
-
|
|
RAND function in SQL Server is used to generate a random value between 0 and 1. When you use RAND in the SELECT statement, it generates the same value for the entire resultset. One of my friends asked me if it is possible to have different random values...
|
|
-
|
|
Money is one of the datatypes in SQL Server and it can be used to store monetary values. It will not only accept integer and decimal values but formatted values too. For example you can express values that include comma and currency symbol
Consider the ...
|
|
-
|
|
The currency symbol $ represents the value 0. Find more examples at http://beyondrelational.com/modules/1/justlearned/tips/8577/arithmetic-operations-with-.aspx
The datatype of the returned value from $ is money.
Consider the following exampledeclare @...
|
|
-
|
|
When viewing the existing table structures, I noticed that one table has a column with datatype defined as VARCHAR(1). I generally do not see this being used.
Given that you need to use a character datatype of maximum length of 1, the question is "Is V...
|
|
-
|
|
You can do conditional aggregation like SUM(CASE WHEN .. THEN 1 ELSE 0 END),....etc to find a count for a particular match. This type of conditions are useful when you want to write a CROSS-TAB/PIVOT Query. You can also make use of COUNT(CASE WHEN .. TH...
|
|
-
|
|
One of my friends asked me if it is possible to load multiple resultsets returned from a stored procedure into a temporary table for some analysis purpose. The answer is "It depends". If all the resultsets return same number of columns then it is possib...
|
|
-
|
|
Assume that you have two identical tables in different servers. The table in production server has 100 million rows and the table in test server is empty and you want to transfer data from production server into test server to do some analysis based on ...
|
|
-
|
|
BCP is one of the fastest methods to export data to various formats like csv,txt,etc and doing this in a command mode is faster than doing it via SSMS.
Let us create this simple tablecreate table test(id int, name varchar(50))
insert into test(id,name)...
|
|