|
|
-
|
|
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......
|
|
-
|
|
Both the functions DATENAME and DATEPART are used to extract the informations from the date. However there is a difference between the two in terms of return datatype. DATENAME function always return the varchar datatype whereas DATEPART functions return Integer datatype Consider the following examp......
|
|
-
|
|
Someone in the forums asked for finding out a string in which each character is same. Consider the following example
declare @t table(data varchar(20))
insert into @t
select '222222222222' as data union all
select '666666663466' union all
select 'aaaaaaaa'+CHAR(32) union all
select 'jjkjkhdg'......
|
|
-
|
|
Sometimes developers use ordinal number of the column instead of actual column name in the SELECT statement.
For example, consider the following statement
SELECT emp_id, first_name,dob, address from employees
When a front end application executes this statement it receives a resultset from the......
|
|
-
|
|
Modulus operator is used to find the remainder after the division. All programming languages have specific operators to find a remainder like mod, rem, etc. In SQL Server, we can use modulus operator %. However we can also use general approach to find a remainder. Here are two methods
Method 1 : U......
|
|