|
|
-
|
|
As we know, in SQL Server we can almost use SET-BASED approach to implement any kind of business logic. Rarely CURSOR is used in some cases. Now the question is "When did you use CURSOR to get better performance than SET-BASED approach?"...
|
|
-
|
|
POWER is one of the mathematical functions used in SQL Server which returns the value of the expression to a specific power. But it rounds the values after 16 digits if the result is more than 16 digits. Consider the following exampledeclare @value deci...
|
|
-
|
|
One of my colleagues asked me "Is there a real practical use of having a table with only one column?" Well. There are some cases where a table with only one column makes sense. Here are some cases I know
1 The numbers or Tally table This table can have...
|
|
-
|
|
One of the common requirements is to generate an alphanumeric incremental values like PA0000000001, PA0000000002, etc. There can be several methods to to this. I will list out some of them
Method 1: Create an identity column and concatenate in SELECT s...
|
|
-
|
|
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...
|
|