|
|
-
|
|
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......
|
|
-
|
|
Sometimes back, my friend told me that they had an application where users update their timesheets. He suspected that some users who had access to the database directly update some entries. He wanted to know whether some users update entries using a query analyser and not using the application. You ......
|
|
-
|
|
Both these functions are used to convert values from one datatype to another But there are some differences between them 1 CAST is ANSI standard and CONVERT is specific to SQL Server 2 CAST can't be used for formating purposes. But CONVERT can be used for formating purposes particularly on datetime ......
|
|
-
|
|
Often people ask how to use InitCap function in SQL Server Initcap is used to capitalise each first letter of the word and keep rest as non-capital Pinal Dave has a post at http://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-caseJoe Celko gave ......
|
|
-
|
|
The symbol dot (.) plays a major role when you write queries It is mainly used to speicify the columns for the respective tables when a join is used as you see in the following example
select
t1.col1,t1.col2,t2.col3,t2.col4
from
table1 as t1 inner join table1 as t2 on t1.col1=t2.col1
......
|
|
-
|
|
''
Begin
Declare @str varchar(1000)
set @str='Exec Master..xp_Cmdshell ''bcp "Select * from '+db_name()+'..'+@table_name+'"
queryout "C:\data\'+@table_name+'.txt" -c'''
Exec(......
|
|
-
|
|
This post follows my previous three posts Part I
Part II
Part IIIBest practices when using datetime values
1 Always use proper DATETIME datatype to store dates This is very important becuase lot of people use varchar datatype to store formatted date values. Only if you use datetime datatype, you......
|
|
-
|
|
This post follows my previous two posts about datetimehttp://beyondrelational.com/blogs/madhivanan/archive/2010/05/25/understanding-datetime-column-part-i.aspxhttp://beyondrelational.com/blogs/madhivanan/archive/2010/05/25/understanding-datetime-column-part-ii.aspxNow we will see some example querie......
|
|
-
|
|
This post follows my blog post Understanding datetime column part I
Date FormatsUnambiguous formats YYYYMMDD YYYYMMDD HH:MM:SS YYYY-MM-DDTHH:MM:SS Ambiguous formats DD/MM/YYYY MM/DD/YYYY DD-MM-YYYY MM-DD-YYYY YYYY-MM-DD etc
Someone wants to input dates in DD/MM/YYYY format
Declare @test table(......
|
|
-
|
|
There are N number of questions asked in the forums about handling dates in query Most of the people who ask questions dont understand how datetime column works in SQL Server Some of the questions frequently asked are about
1 using dates in the WHERE caluse 2 formatting dates using SQL 3 inserting......
|
|