|
|
-
|
|
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
......
|
|
-
|
|
One of my frieds told me that INSERT trigger will not fire if no data are added to the main table. It is a mistake that some people think that triggers will not fire if no row is affected. Note that trigger is event based and not data based.
Here is a proof that trigger fires eventhough no row is ......
|
|
-
|
|
One one my friends asked mw if it is possible to copy the directory structure information with size to a text file. This can be done via any front end application. If you want to do this from SQL Server you can make use of system procedure xp_cmdshell
Consider the follwoing code
DECLARE @cmd sys......
|
|
-
|
|
Jacob Sebastian, SQL Server MVP, started a T-SQL Quiz series in his site which is published each day on March 2011. The SQL Server MVPs and other industry experts ask some questions in SQL Server. If you are a sql developer you are invited to participate in Quiz. There are many questions that are ve......
|
|
-
|
|
PRINT statement is used to return user defined message to the client. However you need to be aware of the return type of the print statement. No matter what the input is, print statement always return data as a varchar datatype (or nvarchar if the input is of nvarchar datatype)
Consider the follow......
|
|
-
|
|
Common table expression(CTE) can be used both in SQL Server and Oracle. However there is a significant difference between them if you use cte to insert data to a table. In SQL server, you need to create a cte first and then insert data to a table. But in ORACLE cte definition should be preceded by i......
|
|
-
|
|
I have already posted two posts about extracting numbers from a string
http://beyondrelational.com/blogs/madhivanan/archive/2007/12/18/extract-only-numbers-from-a-string.aspx
http://beyondrelational.com/blogs/madhivanan/archive/2010/04/22/extracting-numbers-part-2.aspx
Loana in her blog ......
|
|
-
|
|
Someone in the forums asked about the internal storage of the temporary table. The questioner was complaining that the table was not stored in the database
Let us consider this example
create table #t(i int)
Now check the existance of the table in information_schema.tables view
select * from......
|
|
-
|
|
I have already posted a blog post about the usage of sp_who2 in OPENROWSET function. It is not possible to use it because sp_who2 returns duplicate column names (SPID)
In this post we will analyse why it returns duplicate columns
The system procedure sp_who2 gives informations about processes, use......
|
|
-
|
|
One of my friends asked me whether an identity column can be NULL.When he was viewing the table script he noticed that SQL Server adds NOT NULL constraint to identity columns automatically eventhough he did not speficy it when creating a table
Consider the following table script
create table test......
|
|