Created
September 6, 2012 12:40
-
-
Save MachinesAreUs/3655847 to your computer and use it in GitHub Desktop.
Example for creating SQL script from a templat in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
require 'erb' | |
template = ERB.new <<-EOF | |
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'<%= sp_name %>') AND type in (N'P', N'PC')) | |
DROP PROCEDURE <%= sp_name %> | |
GO | |
EOF | |
File.readlines('sps_to_delete.txt').each do |line| | |
sp_name = line.chomp | |
puts template.result(binding) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment