SQL Server to MySQL

Source: Internet
Author: User

Yesterday, my friend asked me how to convert sqlserver to MySQL. I said Baidu. As a result, Baidu still had some problems. Finally, I wrote a script for conversion. By the way, I also learned the shell script.

Post the notes here and sort them out later.

 
Use [huaxindev] Go/****** object: Table [DBO]. [jcrttt] script Date: 06/06/2013 18:14:22 *****/set ansi_nulls ongoset quoted_identifier ongoset ansi_padding ongo create tablecreate table [DBO]. [jcrttt] ([rtyid] [varchar] (20) not null, [caseno] [varchar] (20) null, [riskrecode] [char] (10) null, [money] [numeric] (16, 2) null, constraint [pk_jcresponbility] primary key nonclustered ([responsibilityid] ASC) with (pad_index = OFF, cursor = OFF, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary]) on [primary] goset ansi_padding offgo/***** object: Table [DBO]. [jcreee] script Date: 06/06/2013 18:14:22 ******/

The script is as follows:

 #  ! /Bin/bash Project_name = $1 Name0 = "\/\*\*\*\*\*\*" Name3 = 'Create table' Name1 = 'Constraint' Name2 = '\*\*\*\*\*\*\/' Name4 = "Print 'processed" Name5 = "Insert" Name5 = "Insert" Sed -I's/\ [DBO \]. // G' $1 Sed -I's/\ [// G' $1 Sed -I's/\] // G' $1 Echo * ******** Happy Line 1 *********Beg = 0 End = 0 Lastvalue = 0 Index = 0 Value1 = 'Grep" $ Name4 "-N $1 | cut-d": "-F1 | header-50000 `  Echo Value1 = $ Value1  For I in $ Value1  Do  Index = $ (( $ Index + 1 ) Beg = $ (( $ I -1- $ Lastvalue  ))  #  Echo start: $ beg          End = $ (( $ Beg + 1 ))  #  Echo ended: $ end  Lastvalue = $ (( $ Lastvalue + $ End -$ Beg + 1 ))  #  Echo lastvalue = $ lastvalue          Echo Begin: $ Index Start: $ Beg End: $ End  B = $ (( $ Beg  ) E = $ (( $ End  ) SED -N" $ B P "$1Sed -N" $ E P "$1 Sed -I "$ {beg}, $ {end} D" $1 Done  Echo * ******** Happy split line 2 ********* Beg = 0 End = 0 Lastvalue = 0 Index = 0 Value1 = 'Grep" $ Name0 "-N $1 | cut-d": "-F1 | header-50000 `  Echo Value1 = $ Value1  Value2 = 'Grep" $ Name3 "-N $1 | cut-d": "-F1 | header-50000 `  Echo Value2 = $ Value2  For I in $ Value1  Do  Index = $ (( $ Index + 1 ) Beg = $ (( $ I + 1-$ Lastvalue  ))  #  Echo start: $ beg          For J in $ Value2      Do           If [ $ J -GT $ I  ]; Then  End = $ J              Break  ; FI Done          End = $ (( $ End -1- $ Lastvalue  ))  #  Echo ended: $ end  Lastvalue = $ (( $ Lastvalue + $ End - $ Beg + 1 ))  #  Echo lastvalue = $ lastvalue      Echo Begin: $ Index Start: $ Beg End: $ End  B = $ (( $ Beg -1 ) E = $ (( $ End + 1 ) SED -N" $ B P "$1 Sed -N" $ E P "$1 #  Echo end: $ Index         If [ $ End -Le $ Beg  ]; Then  Echo  Xxxxxxxxxxxxxxxxxxxxxx wrong MSG xxxxxxxxxxxx  Echo Start: $ Beg                  Echo End: $ End                  Echo Testssslastvalue = $ Lastvalue  FI SED -I "$ {beg}, $ {end} D" $1Done  Sed -I's/\ */insert_fuck \/\ */G' $1 Echo * ******** Happy Line 3 ********* Beg = 0 End = 0 Lastvalue = 0 Index = 0 Value1 = 'Grep" $ Name1 "-N $1 | cut-d": "-F1 | header-50000 `  Echo Value1 = $ Value1  Value2 = 'Grep" $ Name5 "-N $1 | cut-d": "-F1 | header-50000 `  Echo Value2 = $ Value2  For I in $ Value1  Do  Index = $ (( $ Index + 1 ) Beg = $ (( $ I - $ Lastvalue  ))  # Echo start: $ beg          For J in $ Value2      Do           If [ $ J -GT $ I  ]; Then  End = $ J              Break  ; FI  Done          End = $ (( $ End -1-$ Lastvalue  ))  #  Echo ended: $ end  Lastvalue = $ (( $ Lastvalue + $ End - $ Beg + 1 ))  #  Echo lastvalue = $ lastvalue      Echo Begin: $ Index Start: $ Beg End:$ End  B = $ (( $ Beg  ) E = $ (( $ End  ) SED -N" $ B P "$1 Sed -N" $ E P "$1 #  Echo end: $ Index          If [ $ End -Le $ Beg ]; Then  Echo  Xxxxxxxxxxxxxxxxxxxxxx wrong MSG xxxxxxxxxxxx  Echo Start: $ Beg                  Echo End: $ End                  Echo Testssslastvalue = $ Lastvalue  FI SED -I "$ {beg}, $ {end} D" $1 Done  Echo * ******** Happy Line 4 ********* Sed -I's/insert/; insert/G' $1Sed -I's/\ */; \/\ */G' $1 Sed -I's/insert_fuck; // G' $1 Echo * ******** I still have two kinds of manual replicas in my day *********

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.