Showing posts with label SQL2005. Show all posts
Showing posts with label SQL2005. Show all posts

Sunday, December 5, 2010

Get current Identity value, Seed value and Increment value in SQL Server

While working with IDENTITY we might want to know the current value of the IDENTITY, the SEED value and the Increment value. So here is the way by which we can quickly get this information.

SELECT IDENT_CURRENT ('customer') AS CurrentIdentity,
IDENT_INCR('customer') AS Incremented_By,IDENT_SEED('customer') AS SeedValue;

--create customer table
CREATE TABLE customer (custid INT IDENTITY NOT NULL,custname VARCHAR(10));

--insert value
INSERT INTO customer(custname) values ('cust1');

--get the Identity values
SELECT IDENT_CURRENT ('customer') AS CurrentIdentity,
IDENT_INCR('customer') AS Incremented_By,IDENT_SEED('customer') AS SeedValue;

Using the above example, I have inserted two records into the customer table. Here is the result of the current Identity values.


CurrentIdentityValues


Happy Learning !!!

Saturday, July 31, 2010

SQL Server Driver for PHP 2.0 CTP2 – June 2010

As of June 2010, the SQL Server Driver for PHP V2.0 CTP2 is available for download.

The SQL Server Driver for PHP is a PHP 5 extension that allows for the reading and writing of SQL Server data from within PHP scripts. The extension provides a native procedural and PDO interfaces for accessing data in all editions of SQL Server 2005 and later including SQL Azure.

Please don’t forget to check the System Requirements. One thing I noticed here is, this driver is for Any edition of SQL Server 2005 or SQL Server 2008.

Click here to get more information : http://www.microsoft.com/downloads/details.aspx?FamilyID=DF4D9CC9-459C-4D75-A503-AE3FCEB85860&displaylang=en

Follow SQLPHP blog here

Happy Learning !!!

Tuesday, July 20, 2010

Deprecated Database Engine Features in SQL Server 2005

Often while upgrading to SQL Server 2005 from the earlier version of SQL Server, you might come across a situation where some of the features are deprecated or not supported. So here is the list of deprecated Database Engine Features in SQL Server 2005

http://msdn.microsoft.com/en-us/library/ms143729(SQL.90).aspx

Happy Learning !!!

Sunday, May 30, 2010

Check current Isolation level in SQL Server

Often we wanted to know the current isolation level set for the SQL Server database. This can be easily checked with the following DBCC command.

DBCC USEROPTIONS;

This command returns the SET options active/configured for the current connection.

Result:

image

Wednesday, May 26, 2010

How to get the list of all the databases in SQL Server

To get the list of all the databases in SQL Server use the following system stored procedure

exec sp_databases;

Result:

DATABASE_NAME DATABASE_SIZE REMARKS
master 5120 NULL
model 2816 NULL
msdb 11264 NULL
ReportServer$SQL2008DEV 10240 NULL
ReportServer$SQL2008DEVTempDB 3072 NULL
SQLThreads 4096 NULL
tempdb 8704 NULL

Alternatively you can also use SQL Query as given below.

SELECT * FROM sys.databases;

image

Thursday, April 22, 2010

SQL Server : ALTER COLUMN – Change the Size of the Column using ALTER Command

We can change the size of the already created column in the table using the ALTER command.

Example:

--Create test table
CREATE TABLE TestAlterCommand
(     EmpNo INT,
      EmpName varchar(10)
);

--Change the size of the column 'EmpName' from 10- 50;
ALTER TABLE TestAlterCommand
 
ALTER COLUMN EmpName varchar(50);

Happy Learning !!!