I am trying to import data from a mySQL database into Microsoft SQL because our company uses a mySQL website and MS-SQL Accounting/ERP system.
Anyways… Some of the fields in mySQL are “serialized”. I am trying to determine how using sure SQL code I could unserialize and read the data into MS SQL. Is this possible, how?
One of the fields looks like this:
a: 9: {
s: 15: "product_options";
a: 2: {
i: 719;
s: 4: "2979";
i: 718;
s: 4: "2975";
}
s: 18: "unlimited_download";
s: 1: "N";
s: 7: "product";
s: 37: "Champion Tagless Ringer Tee - T-Shirt";
s: 10: "company_id";
i: 0;
s: 6: "is_edp";
s: 1: "N";
s: 12: "edp_shipping";
s: 1: "N";
s: 10: "base_price";
d: 9.9900000000000002131628207280300557613372802734375;
s: 12: "stored_price";
s: 1: "N";
s: 21: "product_options_value";
a: 2: {
i: 0;
a: 13: {
s: 9: "option_id";
s: 3: "719";
s: 11: "option_type";
s: 1: "S";
s: 9: "inventory";
s: 1: "Y";
s: 11: "option_name";
s: 5: "Color";
s: 11: "option_text";
s: 0: "";
s: 11: "description";
s: 0: "";
s: 10: "inner_hint";
s: 0: "";
s: 17: "incorrect_message";
s: 0: "";
s: 8: "modifier";
s: 5: "0.000";
s: 13: "modifier_type";
s: 1: "A";
s: 8: "position";
s: 2: "30";
s: 12: "variant_name";
s: 13: "White/Scarlet";
s: 5: "value";
s: 4: "2979";
}
i: 1;
a: 13: {
s: 9: "option_id";
s: 3: "718";
s: 11: "option_type";
s: 1: "S";
s: 9: "inventory";
s: 1: "Y";
s: 11: "option_name";
s: 13: "Clothing Size";
s: 11: "option_text";
s: 0: "";
s: 11: "description";
s: 0: "";
s: 10: "inner_hint";
s: 0: "";
s: 17: "incorrect_message";
s: 0: "";
s: 8: "modifier";
s: 5: "0.000";
s: 13: "modifier_type";
s: 1: "A";
s: 8: "position";
s: 2: "20";
s: 12: "variant_name";
s: 6: "Medium";
s: 5: "value";
s: 4: "2975";
}
}
}
Thank you in advance for any assistance anyone can provide on this.
I’m fairly sure there is no direct equivalent to PHP’s
unserialize()in MS SQL.You would have to build it yourself – it would be far better to try let PHP handle it.