|
|
-
|
|
You can change the datatype of the column with ALTER statement. You may think that it will never change the column values. But there are some cases where altering a datatype can cause changing the value of the column. Consider the following table
create table test(id int, dates varchar(100))
in......
|
|
-
|
|
SQL Server currently supports 37 different datatypes. But Many people may not know that there are some datatypes in SQL Server which are considered as Special datatypes. They are listed below
bit hierarchyid sql_variant sysname table timestamp Alias data types
They are knwon as special datatypes......
|
|
-
|
|
Sometimes you may be on need of knowing what the backup type of the backup file is. For example the backup file may be of full backup, transaction log, diffential database etc. If you want to know it before restoring a database you can use RESTORE HEADERONLY option
Assume that you have a backup fi......
|
|
-
|
|
One of the members in the SQL Server forum asked a question about querying the remote server without actually adding it as a Linked Server. One of the options to do this is to make use of the OPENDATASOURCE function
Assume that you have two servers Server1 and Server2. You want to query a table fro......
|
|
-
|
|
Alias name can be used in such cases like more than a table is used in the select statement, naming a derived column or table, etc. However the usage seems to be different among the RDBMSs. Consider the following examples which are valid in SQL Server
select t.* from table1 as t
select sum(t.a......
|
|
-
|
|
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......
|
|