|
|
-
|
|
The system variable @@TRANCOUNT is used to get the number of transactions that are active. Consider the following code
begin transaction
select 3
select @@TRANCOUNT
commit transaction
The result of @@TRANCOUNT is 1. Consider the following code.
begin transaction
select 3
begin transac......
|
|
-
|
|
As I have informed you earlier in this post, there are some interesting tips I have contributed in December 2011. You may find them interesting if you follow them. The following are some of my tips I posted there
Most Learned Posts of all time
You can drop multiple tables using single DROP stateme......
|
|
-
|
|
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(94),no)))+ replicate(char(94),no*2-1)
from
(
select top 10 row_number() over (order by name) as no from sysobject......
|
|
-
|
|
Often deveopers confuse themselves between Timestamp and Datetime datatypes. But they are entirely different datatypes. Although the name has Time, the Timestamp datatype has nothing to do anything with date or time. Also you cannot explicitely add/update that column. It gets updated whenever data a......
|
|
-
|
|
Assume that there is a database named test in the server and you want to take a backup of that database. Run the following code without specifying the path
backup database test to disk=''
You will get the following error messages
Msg 3044, Level 16, State 2, Line 1
Invalid zero-length device......
|
|
-
|
|
Suppose there are two tables which have 5 and 4 rows respectively and related by the column id. If you want to join these two tables and get data from table1 you can write old style join like below
create table table1 (id int, names varchar(100))
insert into table1
select 1,'test1' union all
s......
|
|
-
|
|
This is just for Fun. The following code is unformatted, unclear and may be confusing. But curious to know the result? Set the result mode of the query window to Text . While you are in Query Window press CONTROL+T and run the following code and see what it returns.
......
|
|
-
|
|
As I have informed you earlier in this post, there are some interesting tips I have contributed in November 2011. You may find them interesting if you follow them. The following are some of my tips I posted there
Most Learned Posts of all time
You can drop multiple tables using single DROP stateme......
|
|
-
|
|
I had blogged about Different ways to know structure of the tables. One of the methods is to highlight the object name and press Alt+F1. But this will not work if the object name contains multiparts ie database name, owner name etc.
Consider the following object
sys.objects
Applying Alt+F1 wil......
|
|
-
|
|
There are many aggregate functions available in SQL Server. One thing that most of the people forget is that Aggregate functions always return atleast a row no matter if there are rows in the table or where clause returns or does not return any resultset
Consider the following example
declare @t......
|
|