++ed by:
ELLIOTT TIMB OALDERS AWNCORP DJO

104 PAUSE users
105 non-PAUSE users.

Peter Rabbitson
and 1 contributors

NAME

DBIx::Class::Storage::DBI::MSSQL - Base Class for Microsoft SQL Server support in DBIx::Class

SYNOPSIS

This is the base class for Microsoft SQL Server support, used by DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server and DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server.

IMPLEMENTATION NOTES

IDENTITY information

Microsoft SQL Server supports three methods of retrieving the IDENTITY value for inserted row: IDENT_CURRENT, @@IDENTITY, and SCOPE_IDENTITY(). SCOPE_IDENTITY is used here because it is the safest. However, it must be called is the same execute statement, not just the same connection.

So, this implementation appends a SELECT SCOPE_IDENTITY() statement onto each INSERT to accommodate that requirement.

SELECT @@IDENTITY can also be used by issuing:

  $self->_identity_method('@@identity');

it will only be used if SCOPE_IDENTITY() fails.

This is more dangerous, as inserting into a table with an on insert trigger that inserts into another table with an identity will give erroneous results on recent versions of SQL Server.

identity insert

Be aware that we have tried to make things as simple as possible for our users. For MSSQL that means that when a user tries to create a row, while supplying an explicit value for an autoincrementing column, we will try to issue the appropriate database call to make this possible, namely SET IDENTITY_INSERT $table_name ON. Unfortunately this operation in MSSQL requires the db_ddladmin privilege, which is normally not included in the standard write-permissions.

AUTHOR

See "CONTRIBUTORS" in DBIx::Class.

LICENSE

You may distribute this code under the same terms as Perl itself.