|
|
-
|
|
Pinal Dave, Blogger,Speaker,Evangelist and Author,in his blog posted a puzzle about SQL SERVER – A Puzzle – Swap Value of Column Without Case StatementConsider the following set of data USE tempdb
GO
CREATE TABLE SimpleTable (ID INT, Gender VARCHAR(10...
|
|
-
|
|
Run the following code
declare @t table(i int unique)
insert into @t
select 1 union all
select null union all
select null
You will get the following error
Msg 2627, Level 14, State 1, Line 3
Violation of UNIQUE KEY constraint 'UQ__#A989971__3BD019979D26A3BB'. Cannot insert duplica......
|
|
-
|
|
I see developers often confused on how they get the list of objects by IntelliSense when writing the code. Here are some points on how you can intelligently make use of IntelliSense.
When IntelliSense is enabled, in the query window, type SELECT and a s...
|
|
-
|
|
Arithmetic operators are used to perform arithmetic operations like addition, subtraction, multiplication and division. However the operators + ,- and ~ can also be used as unary operators to decide if a number is positive or negative. But we can have f...
|
|
-
|
|
The batch separator in SQL Server signals the end of the batch. By default SQL Server uses GO as the batch separator. However often people get confused on when they should use it compulsorily. Here are the cases where you must use batch separator
1 A...
|
|
-
|
|
DateSerial function accepts three paramter values year,month and day and return a valid date value with time set to midnight. SQL Server does not support this function until version 2012 is released.
There can be many ways to simulate this functionality...
|
|
-
|
|
There is a blog post about #TSQL CAST Conversion Error… give me the row please! where the posted showed some methods to identify the data where convertion error happens. Here are other approaches to identify the problamatic data. Consider the following ...
|
|
-
|
|
Consider the following two statements
--Query 1 select
name,
dateadd(day,datediff(day,0,create_date),0) as date_only
from
sys.objects
where
date_only>getdate()-100
--Query 2 select
name,
dateadd(day,datediff(day,0,create_date),0) as...
|
|
-
|
|
Consider the following table
create table #t(id int, names varchar(100))
insert into #t
select 1,'name1'
union all
select 2,'name2'
Consider the following select statement
select id from #t
order by id,id
It returns the error
Msg 169, Level 15, State 1, Line 3
A column has been spe......
|
|
-
|
|
Handling DATETIME values in the queries is often challenging due to various factors which include choosing wrong datatype(VARCHAR instead of DATETIME),formatting in sql,expressing values in regional specific format,removing time part,etc.
Well. Here is...
|
|