|
|
-
|
|
SEQUENCE is introduced in version 2012. It is an object which can be used to generated customised SEQUENCE numbers that be used across many objects in the database. A SEQUENCE can be directly/indirectly bound with objects.
Consider the following SEQUEN...
|
|
-
|
|
Run the following code
select ' ' ' ' -- Query 1
select '''' -- Query 2
How does the first query return single space whereas the second query returns single single quote?...
|
|
-
|
|
Did you know that table variables are stored in the tempdb database for execution scope only?. Ok. Let us run this code
declare @t table(i int)
select * from tempdb.INFORMATION_SCHEMA.TABLES
The result is
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
--------------------......
|
|
-
|
|
As you all know tempdb is responsible of storing all the temporary objects created for a server. One of my co-workers asked me "what is the scope of permanent tables created in the tempdb database?". The answer is it can be accessed via tempdb from various connections just like objects are accessed ......
|
|
-
|
|
As you know NULL is the absence of data and any datatype can be NULL. But by default a NULL value is considered to be of INT datatype. Let us run the following code
select null as t into #t
GO
exec tempdb..sp_help #t
A NULL value is copied to a temporary table #t. Second resultset of sp_help ......
|
|
-
|
|
I am starting this series of questions which will be posted every month. You may find them interesting to answer. This is the question for this month.
What does SQL Server return for the following select statement?
SELECT 7A
Post your answer and breifly explain the output.
Keep following t......
|
|
-
|
|
When I was viewing someone's code, I have noticed that the date values were not
compared as dates but they were converted to varchar before comparision
Suppose, you want find out the objects that were created in February 2011. The correct
code is
select
name
from
......
|
|
-
|
|
In the Query Analyser, set the Result mode to Text (Press CTRL+T) and run the following code
set nocount on
select
space(17-len(replicate(char(37),no)))+ replicate(char(37),no*2-1)
from
(
select top 10 row_number() over (order by name) as no from sysobjec......
|
|
-
|
|
We frequently use some datatypes like INT, CHAR, VARCHAR,etc. But there are currently 37 datatype supported by SQL Server. If you want to know the list of supported datatype, run the following methods
Method 1 : Use system stored procedure sp_datatype_info
exec sp_datatype_info
Method 2 : Us......
|
|
-
|
|
Sometimes, you may need to find a value in the characters columns (char, varchar, etc) in all
the tables
This is one of the methods to do it
declare @sql varchar(max),@search varchar(100)
set @sql=''
set @search='your search string'
select
@sql=@sql+'select distinct ''['+c......
|
|