# Rake Task insert record from MySqlDB to SqlServerDB

**URL:** <https://www.ruby-forum.com/t/rake-task-insert-record-from-mysqldb-to-sqlserverdb/160516>\
**Category:** Rails\
**Created:** [February 17, 2009, 10:33am UTC](https://www.ruby-forum.com/t/rake-task-insert-record-from-mysqldb-to-sqlserverdb/160516 "2009-02-17T10:33:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakenewuser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e480ec/32.png) [@rakenewuser](https://www.ruby-forum.com/u/rakenewuser)\
**Post date:** [February 17, 2009, 10:33am UTC](https://www.ruby-forum.com/t/rake-task-insert-record-from-mysqldb-to-sqlserverdb/160516/1 "2009-02-17T10:33:46Z")

</div>

Hi,

Anyone can help, to my script see the list below. I want to insert from  
MySqlDB to SqlServerDB. Currently, my script will insert the entire data  
but I need to truncate the table first from SqlServerDB on ISQL command  
line manually.

Is there a way directly to insert the data without truncating the table  
mytalbes on SqlServerDB?

# Start Here

# rake utils:staging

n# rake utils:staging  
namespace :utils do  
task :staging =\> :environment do  
FileList.new(‘app/\*\*/\*’) { |list|  
translations = []  
list.each { |file\_path|  
unless File::directory?(file\_path)  
file = File.open(file\_path, ‘r’)  
file.each { |line|  
translations = translations |  
line.scan(/’"[’"].t/)  
}  
file.close  
end  
}  
# MySqlDB Unix getting the data here  
ActiveRecord::Base.establish\_connection(:development)  
mytables = Mytable.find :all

```
    # SqlServerDB Windows insert the data not existing on MysqlDB

```

Unix  
ActiveRecord::Base.establish\_connection(:production)  
mytables.each { |mytable| Mytable.create mytable.attributes }  
}  
end  
end

# End Here

Thanks in Advance!
