|
|
-
|
|
Suppose you have a set of codes and when a particular condition is true, you want to terminate or switch to another set of code, you can use Break commnad. I see sometimes people use return commnad for this. But there is a significant difference between these two. Consider this example
Usage of BR......
|
|
-
|
|
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......
|
|
-
|
|
You know that Create or alter procedure statement should be always in a seperate batch otherwise you will get an error "'CREATE/ALTER PROCEDURE' must be the first statement in a query batch." Sometime when you want to create or alter the procedure based on the existance of a procedure you may wonder......
|
|
-
|
|
If you want to count the number that exceeds the maximum value of INT datatype, you can make use of COUNT_BIG function. COUNT_BIG function always returns a bingint datatype value. Consider the following example code which uses both COUNT_BIG and COUNT function
select COUNT_BIG(*) as big_number, COU......
|
|
-
|
|
In this blog post, I have already blogged about knowing version of the server using different methods. One other method is to make use of @@MicrosoftVersion frunction
select @@MicrosoftVersion,CAST(@@MicrosoftVersion as binary(5))
The result is
------------ ------------
167773760 0x000A00......
|
|
-
|
|
Quotename() function is used to return a unicode string with delimiters. A delimiter can be a single quote, double quote or braces ( or [.
select
quotename('test','''') as single_quote,
quotename('test','"') as double_quote,
quotename('test','(') as brace,
quotename('test','[') as sqaure......
|
|
-
|
|
The symbol @ is mainly used to identify a variable, parameter and table variable. The usage of @ sometimes make you to have some fun. Here are some methods
You can declare a table variable with only @s. Cosider this example
declare @@@ table(i int )
insert into @@@(i) select 345
select i from ......
|
|
-
|
|
The following methods can be used to know the parameter informations of the particular stored procedure
Let us consider the following procedure
create procedure testing
(
@id int,
@user_name varchar(100),
@join_date datetime
)
as
select @id as userid, @user_name as username,@join_date ......
|
|
-
|
|
There are many ways to know the version of the Current Server using a query. They are shown below
1 Use @@version
select @@version
2 Use system procedure sp_server_info and see the value of attribute_value column where attribute_name is DBMS_VER
EXEC sp_server_info
3 Use system procedure e......
|
|
-
|
|
Regular expression can be effectively used to get performance benefit in certain cases. Consider the following customers table where custid is the primary key.
Source Data
declare @customers table
(
custid varchar(10) primary key,
custname varchar(100),
zipcode char(6)
)
insert into @custo......
|
|