Skip to content

Instantly share code, notes, and snippets.

@metaskills
Last active March 17, 2017 13:32
Show Gist options
  • Select an option

  • Save metaskills/5bf99b67fa5c2473839981130c2d233b to your computer and use it in GitHub Desktop.

Select an option

Save metaskills/5bf99b67fa5c2473839981130c2d233b to your computer and use it in GitHub Desktop.
require 'tiny_tds'
puts 'Connecting to SQL Server'
@client = TinyTds::Client.new(
host: 'localhost', port: 1433,
username: 'sa', password: ENV['SA_PASSWORD'],
database: 'SampleDB'
)
def execute(sql)
@client.execute(sql).do
true
end
execute "CREATE TABLE Employees (Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY, Name NVARCHAR(50), Location NVARCHAR(50))"
execute "INSERT INTO Employees (Name, Location) VALUES (N'Jared', N'Australia'), (N'Nikita', N'India'), (N'Tom', N'Germany')"
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment