|
|
-
|
|
NULL. This is a magical word in Database programming. Here are some interesting facts about NULL in SQL Server.
1 NULL can be defined as absense of value, undefined, or the value which is unknown at this point of time.2 All datatypes can be defined with...
|
|
-
|
|
As you know both CHAR and VARCHAR datatypes are used to store characters. While VARCHAR is preferred and used in many times to have data with varying length CHAR datatype is primarily used to have data with Fixed length. Also CHAR datatype will keep tra...
|
|
-
|
|
My Co-worker complained me that AVG function is not properly working in SQL Server whereas it works correctly in mysql. I immediately told him that AVG does the implicit convertion by default and the result may be wrong (based on datatype).
Consider th...
|
|
-
|
|
Square braces in SQL Server play a major role in T-SQL programming. When an object name contains a space, special character, etc, the only way to express them is to put them around squre braces. Consider that you want to create a table user master (with spaces between user and master), you can use [u......
|
|
-
|
|
I have posted a question for July 2012 at Question of the month July 2012 - How does COALESCE(null,null+1,null) work? Did you know why the second query works without any error?
A NULL value can be of two types. Typed NULL and non-Typed NULL.
SELECT SUM...
|
|
-
|
|
As you know well, VALUES clause is used to insert values to the table
A simple example is
declare @t table (id int , col1 int, col2 int, col3 int)
insert into @t values(1, 14, 12, 24)
select * from @t
But in version 2008, you can do more things using VALUES clause than the previous versions......
|
|
-
|
|
Both SET and SELECT clauses can be used to assign values to the variables. While SET works for a single variable, SELECT works for more than a variable. If you want to assign values to multiple variables in single shot, SELECT can be used.
SELECT serv...
|
|
-
|
|
My friend told me that in an interview he was asked to write a code that sums the digits of the number. He asked me if there is a way of doing it without using a WHILE loop. Here are two methods
Method 1 : Dynamic SQLdeclare @i int, @sql varchar(8000)
s...
|
|
-
|
|
My friend asked me to come up with very triky interview question which is not usually asked. I myself asked this question to some of candidates while interviewing. It is possible to to apply arithmetic operators + and - on date columns like Date+2, Date...
|
|
-
|
|
Consider the following CREATE TABLE statementscreate table #t1 (i int) -- Statement 1
create table .#t2 (i int) -- Statement 2
create table ..#t3 (i int) -- Statement 3
create table ...#t4(i int) -- Statement 4
How many are incorrect stateme...
|
|