|
|
-
|
|
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...
|
|
-
|
|
When you write queries that involve datetime columns, it is often needed to remove time part from datetime value to compare only date part. An example would be, you have table called sales_details that has sales_date as one of the columns and you want t...
|
|
-
|
|
Ok. Here is some Fun. This is the script that will produce zero without using any number in the code. Post your code if you find any such method
select
$,
$+,
$+.,
-$,
$*$,
+$-,
($),
$.,
($.),
-+$-,
+-$+.,
-$+.+$.,
'$,'-$+,
'$,.'-$-.
Run the code and see the output.......
|
|
-
|
|
One of the features available in SQL Server 2005 is Row_Number() function. It is not only used to generate row number for each row but also used for other purposes as well. I breifly explain how it can be used for various purposes
Consider the following data
Declare @t table(item varchar(100), p......
|
|
-
|
|
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...
|
|
-
|
|
The PIVOT operator available in SQL Server 2005 is used to generate the Cross-tab results
Consider this example
select * from
(
select Year(OrderDate) as pivot_col,e.lastname, o.OrderDate FROM northwind..Employees as e
INNER JOIN northwind..Orders as o ON (e.EmployeeID=o.EmployeeI......
|
|
-
|
|
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...
|
|
-
|
|
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......
|
|
-
|
|
Yes but partly. Let us explore this with examples
We have a system procedure sp_who that returns the informations about the current connections, users, sessions etc. Let us create a new database named test and create sp_who inside it.
Case 1
Create database test
GO
Use test
GO
create procedu......
|
|
-
|
|
Without running the query, can you guess the answer?
Query
select 100.-89_90
Answers
Answer 1 : Incorrect syntax near .
Answer 2 : _79
Answer 3 : Incorrect syntax near 89_90
Answer 4 : 11
......
|
|