=for comment POD_DERIVED_INDEX_GENERATED
The following documentation is automatically generated.  Please do not edit
this file, but rather the original, inline with DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server
at lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.

=cut

=head1 NAME

DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server - Support specific
to Microsoft SQL Server over ODBC

=head1 DESCRIPTION

This class implements support specific to Microsoft SQL Server over ODBC.  It is
loaded automatically by by DBIx::Class::Storage::DBI::ODBC when it detects a
MSSQL back-end.

Most of the functionality is provided from the superclass
L<DBIx::Class::Storage::DBI::MSSQL>.

=head1 USAGE NOTES

=head2 Basic Linux Setup (Debian)

  sudo aptitude install tdsodbc libdbd-odbc-perl unixodbc

In case it is not already there put the following (adjust for non-64bit arch) in
C</etc/odbcinst.ini>:

  [FreeTDS]
  Description = FreeTDS
  Driver      = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
  Setup       = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
  UsageCount  = 1

Set your C<$dsn> in L<connect_info|DBIx::Class::Storage::DBI/connect_info> as follows:

  dbi:ODBC:server=<my.host.name>;port=1433;driver=FreeTDS;tds_version=8.0

If you use the EasySoft driver (L<http://www.easysoft.com>):

  dbi:ODBC:server=<my.host.name>;port=1433;driver=Easysoft ODBC-SQL Server

=head2 Basic Windows Setup

Use the following C<$dsn> for the Microsoft ODBC driver:

  dbi:ODBC:driver={SQL Server};server=SERVER\SQL_SERVER_INSTANCE_NAME

And for the Native Client:

  dbi:ODBC:driver={SQL Server Native Client 10.0};server=SERVER\SQL_SERVER_INSTANCE_NAME

Go into Control Panel -> System and Security -> Administrative Tools -> Data
Sources (ODBC) to check driver names and to set up data sources.

Use System DSNs, not User DSNs if you want to use DSNs.

If you set up a DSN, use the following C<$dsn> for
L<connect_info|DBIx::Class::Storage::DBI/connect_info>:

  dbi:ODBC:dsn=MY_DSN

=head1 MULTIPLE ACTIVE STATEMENTS

The following options are alternative ways to enable concurrent executing
statement support. Each has its own advantages and drawbacks and works on
different platforms. Read each section carefully.

For more details about using MAS in MSSQL over DBD::ODBC see this excellent
document provided by EasySoft:
L<http://www.easysoft.com/developer/languages/perl/multiple-active-statements.html>.

In order of preference, they are:

=over 8

=item * L<mars|/connect_call_use_mars>

=item * L<dynamic_cursors|/connect_call_use_dynamic_cursors>

=item * L<server_cursors|/connect_call_use_server_cursors>

=back

=head1 METHODS

=head2 connect_call_use_mars

Use as:

  on_connect_call => 'use_mars'

in your connection info, or alternatively specify it directly:

  Your::Schema->connect (
    $original_dsn . '; MARS_Connection=Yes',
    $user,
    $pass,
    \%attrs,
  )

Use to enable a feature of SQL Server 2005 and later, "Multiple Active Result
Sets". See L<DBD::ODBC::FAQ/Does DBD::ODBC support Multiple Active Statements?>
for more information.

This does not work on FreeTDS drivers at the time of this writing, and only
works with the Native Client, later versions of the Windows MS ODBC driver, and
the Easysoft driver.

=head2 connect_call_use_dynamic_cursors

Use as:

  on_connect_call => 'use_dynamic_cursors'

Which will add C<< odbc_cursortype => 2 >> to your DBI connection
attributes, or alternatively specify the necessary flag directly:

  Your::Schema->connect (@dsn, { ... odbc_cursortype => 2 })

See L<DBD::ODBC/odbc_cursortype> for more information.

If you're using FreeTDS, C<tds_version> must be set to at least C<8.0>.

This will not work with CODE ref connect_info's.

B<WARNING:> on FreeTDS (and maybe some other drivers) this will break
C<SCOPE_IDENTITY()>, and C<SELECT @@IDENTITY> will be used instead, which on SQL
Server 2005 and later will return erroneous results on tables which have an on
insert trigger that inserts into another table with an C<IDENTITY> column.

B<WARNING:> on FreeTDS, changes made in one statement (e.g. an insert) may not
be visible from a following statement (e.g. a select.)

B<WARNING:> FreeTDS versions > 0.82 seem to have completely broken the ODBC
protocol. DBIC will not allow dynamic cursor support with such versions to
protect your data. Please hassle the authors of FreeTDS to act on the bugs that
make their driver not overly usable with DBD::ODBC.

=head2 connect_call_use_server_cursors

Use as:

  on_connect_call => 'use_server_cursors'

May allow multiple active select statements. See
L<DBD::ODBC/odbc_SQL_ROWSET_SIZE> for more information.

Takes an optional parameter for the value to set the attribute to, default is
C<2>.

B<WARNING>: this does not work on all versions of SQL Server, and may lock up
your database!

At the time of writing, this option only works on Microsoft's Windows drivers,
later versions of the ODBC driver and the Native Client driver.

=head1 INHERITED METHODS

=over 4

=item L<DBIx::Class::Storage::DBI::MSSQL>

L<last_insert_id|DBIx::Class::Storage::DBI::MSSQL/last_insert_id>, L<sql_limit_dialect|DBIx::Class::Storage::DBI::MSSQL/sql_limit_dialect>, L<sqlt_type|DBIx::Class::Storage::DBI::MSSQL/sqlt_type>

=item L<DBIx::Class::Storage::DBI::UniqueIdentifier>

L<new_guid|DBIx::Class::Storage::DBI::UniqueIdentifier/new_guid>

=item L<DBIx::Class::Storage::DBI>

L<auto_savepoint|DBIx::Class::Storage::DBI/auto_savepoint>, L<bind_attribute_by_data_type|DBIx::Class::Storage::DBI/bind_attribute_by_data_type>, L<build_datetime_parser|DBIx::Class::Storage::DBI/build_datetime_parser>, L<columns_info_for|DBIx::Class::Storage::DBI/columns_info_for>, L<connect_call_datetime_setup|DBIx::Class::Storage::DBI/connect_call_datetime_setup>, L<connect_call_do_sql|DBIx::Class::Storage::DBI/connect_call_do_sql>, L<connect_info|DBIx::Class::Storage::DBI/connect_info>, L<connected|DBIx::Class::Storage::DBI/connected>, L<create_ddl_dir|DBIx::Class::Storage::DBI/create_ddl_dir>, L<datetime_parser|DBIx::Class::Storage::DBI/datetime_parser>, L<datetime_parser_type|DBIx::Class::Storage::DBI/datetime_parser_type>, L<dbh|DBIx::Class::Storage::DBI/dbh>, L<dbh_do|DBIx::Class::Storage::DBI/dbh_do>, L<delete|DBIx::Class::Storage::DBI/delete>, L<deploy|DBIx::Class::Storage::DBI/deploy>, L<deployment_statements|DBIx::Class::Storage::DBI/deployment_statements>, L<disable_sth_caching|DBIx::Class::Storage::DBI/disable_sth_caching>, L<disconnect|DBIx::Class::Storage::DBI/disconnect>, L<disconnect_call_do_sql|DBIx::Class::Storage::DBI/disconnect_call_do_sql>, L<ensure_connected|DBIx::Class::Storage::DBI/ensure_connected>, L<get_dbms_capability|DBIx::Class::Storage::DBI/get_dbms_capability>, L<get_use_dbms_capability|DBIx::Class::Storage::DBI/get_use_dbms_capability>, L<insert|DBIx::Class::Storage::DBI/insert>, L<insert_bulk|DBIx::Class::Storage::DBI/insert_bulk>, L<is_datatype_numeric|DBIx::Class::Storage::DBI/is_datatype_numeric>, L<is_replicating|DBIx::Class::Storage::DBI/is_replicating>, L<lag_behind_master|DBIx::Class::Storage::DBI/lag_behind_master>, L<new|DBIx::Class::Storage::DBI/new>, L<on_connect_call|DBIx::Class::Storage::DBI/on_connect_call>, L<on_connect_do|DBIx::Class::Storage::DBI/on_connect_do>, L<on_disconnect_call|DBIx::Class::Storage::DBI/on_disconnect_call>, L<on_disconnect_do|DBIx::Class::Storage::DBI/on_disconnect_do>, L<relname_to_table_alias|DBIx::Class::Storage::DBI/relname_to_table_alias>, L<select|DBIx::Class::Storage::DBI/select>, L<select_single|DBIx::Class::Storage::DBI/select_single>, L<set_dbms_capability|DBIx::Class::Storage::DBI/set_dbms_capability>, L<set_use_dbms_capability|DBIx::Class::Storage::DBI/set_use_dbms_capability>, L<source_bind_attributes|DBIx::Class::Storage::DBI/source_bind_attributes>, L<sql_maker|DBIx::Class::Storage::DBI/sql_maker>, L<sql_maker_class|DBIx::Class::Storage::DBI/sql_maker_class>, L<sql_name_sep|DBIx::Class::Storage::DBI/sql_name_sep>, L<sql_quote_char|DBIx::Class::Storage::DBI/sql_quote_char>, L<sth|DBIx::Class::Storage::DBI/sth>, L<svp_begin|DBIx::Class::Storage::DBI/svp_begin>, L<svp_release|DBIx::Class::Storage::DBI/svp_release>, L<svp_rollback|DBIx::Class::Storage::DBI/svp_rollback>, L<txn_begin|DBIx::Class::Storage::DBI/txn_begin>, L<txn_commit|DBIx::Class::Storage::DBI/txn_commit>, L<txn_do|DBIx::Class::Storage::DBI/txn_do>, L<txn_rollback|DBIx::Class::Storage::DBI/txn_rollback>, L<unsafe|DBIx::Class::Storage::DBI/unsafe>, L<update|DBIx::Class::Storage::DBI/update>, L<with_deferred_fk_checks|DBIx::Class::Storage::DBI/with_deferred_fk_checks>

=item L<DBIx::Class::Storage>

L<cursor|DBIx::Class::Storage/cursor>, L<cursor_class|DBIx::Class::Storage/cursor_class>, L<debug|DBIx::Class::Storage/debug>, L<debugcb|DBIx::Class::Storage/debugcb>, L<debugfh|DBIx::Class::Storage/debugfh>, L<debugobj|DBIx::Class::Storage/debugobj>, L<savepoints|DBIx::Class::Storage/savepoints>, L<schema|DBIx::Class::Storage/schema>, L<set_schema|DBIx::Class::Storage/set_schema>, L<throw_exception|DBIx::Class::Storage/throw_exception>, L<transaction_depth|DBIx::Class::Storage/transaction_depth>, L<txn_scope_guard|DBIx::Class::Storage/txn_scope_guard>

=back

=head1 AUTHOR

See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.

=head1 LICENSE

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

