Presentation is loading. Please wait.

Presentation is loading. Please wait.

Please remember to thank our sponsors!

Similar presentations


Presentation on theme: "Please remember to thank our sponsors!"— Presentation transcript:

1 Please remember to thank our sponsors!
All these awesome sponsors! Visit the vendors Thank them if you can!

2 MSSQL is Coming to Linux Are You Ready? Nem W. Schlecht

3 MSSQL is coming to Linux!! LAMP=
Big things are coming! MSSQL is coming to Linux!! LAMP= Linux Apache MySQL/MariaDB/MSSQL PHP/Perl/Python Big news! Microsoft usually doesn’t like support non-Microsoft operating systems

4 So what??? Completely free MSSQL SQL Express Linux VirtualBox
Windows Server 2012 (eval) VirtualBox + Puppet/Ancible = quick dev environments

5 Some questions… What won’t be there? Clustering
Access to registry values SSMS (on Linux) Too reliant on underlying windows OS VisualStudio on Linux IS a possibility!

6 Most things should work
Some answers Easy install apt-get install mssql-server Most things should work Replication Mirroring HA Backups Linux has *much* better underlying filesystems

7 Just the database engine
Some answers Just the database engine No Reporting Services No Analysis Services For now…

8 Sign up for notifications on MSSQL on Linux
Sign up today! Sign up for notifications on MSSQL on Linux

9 What about now? What can we do now? Port applications to MSSQL
Access MSSQL from Linux

10 Use linked servers on MSSQL FreeTDS library on Linux
First steps Use linked servers on MSSQL Connect to Linux databases FreeTDS library on Linux Yes! You can access MSSQL from Linux already!

11 Connect to any DB with an ODBC connector
Linked Servers Connect to any DB with an ODBC connector MySQL PostgreSQL SQLite

12 Link to external database
Linked Servers Link to external database Install DB OBCD driver Connect to DB Add Linked Server Query away

13 Linked Servers OPENQUERY() Query external database

14 Linked Servers - SELECT
FROM OPENQUERY(MySQLdb, ' SELECT id , name , age , address , active FROM users WHERE active = "y" ');

15 Linked Servers - INSERT (What?)
INSERT INTO OPENQUERY(MySQLdb, ' SELECT id , name , age , address FROM users WHERE 1=0 ') VALUES ( 'nem' , 41 , '123 Town Street, Anycity USA, 12345' );

16 Linked Servers - UPDATE
OPENQUERY(MySQLdb, ' SELECT id , name , age , address FROM users WHERE name = "nem" ') SET age = 41;

17 Linked Servers - DELETE
OPENQUERY(MySQLdb, ' SELECT id , name , age , address FROM users ') WHERE name = ‘nem’ ;

18 Linked Servers - Copy Table
SELECT name , age , address , active INTO users FROM OPENQUERY(MySQLdb, ' SELECT id , name , age , address FROM users ');

19 Linked Servers - Fun Stuff
Join a MySQL table to an SQLite table Connect to a MySQL database over an SSH tunnel Use VIEWs to simplify OPENQUERY

20 Linked Servers - Demo Demo

21 FreeTDS library Connect to MSSQL Servers from Linux (and Mac) Use: PHP
Perl Python Ruby Command Line Utilities Bash Scripts

22 FreeTDS Configuration
/etc/freetds/freetds.conf [global] tds version = auto text size = 64512 client charset = UTF-8 [localdb] host = localhost instance = MSSQLSERVER port = 1433 tds version = 8.0

23 FreeTDS Configuration (multiple names)
[localdb] host = localhost instance = MSSQLSERVER port = 1433 tds version = 8.0 [appdevdb]

24 FreeTDS Configuration Instance
[appqadb] host = localhost instance = APPQA port = 14331 tds version = 8.0

25 FreeTDS Utilities tsql defncopy datacopy
Test SQL connection, but can run any SQL defncopy Print out CREATE statement for SQL object datacopy Copy data between servers

26 FreeTDS Utilities freebcp fisql osql bcp clone Interactive SQL shell
OSQL clone (uses ODBC)

27 FreeTDS Utilities Demos

28 FreeTDS Library Uses existing language database API

29 FreeTDS Library API (Perl)
#!/usr/bin/perl use DBI; $db = "nemdev"; my $dbh = DBI->connect("dbi:Sybase:$db" , "$ENV{DBI_USER}" , "$ENV{DBI_PASS}") || die "No DB Connect"; $dbh->do("USE tempdb"); $dbh->do("DROP TABLE test_table"); $dbh->do("CREATE TABLE test_table (test_field VARCHAR(10))");

30 FreeTDS Library API (Perl cont.)
my $sth = $dbh->prepare(" INSERT INTO test_table (test_field) VALUES (?) "); is just some text); for { $sth->execute($_); } $sth->finish();

31 FreeTDS Library API (cont.)
$sth = $dbh->prepare(" SELECT test_field FROM test_table ORDER BY test_field "); $sth->execute(); while = $sth->fetchrow()) { print "Row } $sth->finish(); $dbh->disconnect();

32 FreeTDS Library API (PHP)
<?php $link = mssql_connect('nemdev', 'nem', 'S3cr3t!'); if (!$link) die('Unable to connect!'); if (!mssql_select_db(tempdb', $link)) die('Unable to select database!'); $result = mssql_query('SELECT test_field FROM test_table'); while ($row = mssql_fetch_array($result)) { var_dump($row); } mssql_free_result($result); ?>

33 Questions? Wake Up!

34 Contact Info Nem W. Schlecht PASS Fargo Chapter sqlpass.org – search for "Fargo“


Download ppt "Please remember to thank our sponsors!"

Similar presentations


Ads by Google