{"id":821,"date":"2014-03-23T22:25:12","date_gmt":"2014-03-23T12:25:12","guid":{"rendered":"http:\/\/www.moneystock.net\/wp_e\/?p=821"},"modified":"2014-03-23T22:29:41","modified_gmt":"2014-03-23T12:29:41","slug":"useful-command-of-mssql-query-when-comparing-and-manipulating-text-data","status":"publish","type":"post","link":"https:\/\/moneystock.net\/wp_e\/2014\/03\/23\/useful-command-of-mssql-query-when-comparing-and-manipulating-text-data\/","title":{"rendered":"Useful command of MSSQL Query when comparing and manipulating text data"},"content":{"rendered":"<p>Extract table from another table<\/p>\n<p style=\"padding-left: 30px;\">SELECT *<br \/>\nFROM <span class=\"GINGER_SOFTWARE_mark\" id=\"e417af6b-e7a0-460c-bcc7-f9a4f4aec99f\"><span class=\"GINGER_SOFTWARE_mark\" id=\"e93da8d6-6491-4923-97bf-755bc28fc82c\">dbo<\/span><\/span><span class=\"GINGER_SOFTWARE_mark\" id=\"537971f6-a618-4ac6-bd34-00a50c68a0c7\"><span class=\"GINGER_SOFTWARE_mark\" id=\"6dd5b456-24ac-4b90-8d19-ca97b25f1e91\">.<\/span><\/span>SFG_Event_21_22<br \/>\n<span class=\"GINGER_SOFTWARE_mark\" id=\"f8a429dd-8279-43c3-9805-7fc812efa058\"><span class=\"GINGER_SOFTWARE_mark\" id=\"66367a03-aebc-473a-a3c1-d9c950ba133f\">except<\/span><\/span><br \/>\nSELECT *<br \/>\nFROM <span class=\"GINGER_SOFTWARE_mark\" id=\"b4acea0f-7622-4613-a2e0-789fef7e9c12\"><span class=\"GINGER_SOFTWARE_mark\" id=\"8d563403-5cf7-4ef5-bdce-058353452f8f\">dbo<\/span><\/span><span class=\"GINGER_SOFTWARE_mark\" id=\"008dfa9e-5677-4d41-a086-4d02cb8f3e4a\"><span class=\"GINGER_SOFTWARE_mark\" id=\"20484827-43cb-4031-aafd-1bc36a9c66cc\">.<\/span><\/span>SFG_Event_21<\/p>\n<p>Bulk insert<\/p>\n<p style=\"padding-left: 30px;\">BULK insert <span class=\"GINGER_SOFTWARE_mark\" id=\"2c28f811-481a-4973-a83c-ad19bf1eb53a\"><span class=\"GINGER_SOFTWARE_mark\" id=\"7fa8b983-2073-4505-8a71-d131a3431c13\">dbo<\/span><\/span><span class=\"GINGER_SOFTWARE_mark\" id=\"32f7a210-a599-42e5-bee9-367dee0ceec4\"><span class=\"GINGER_SOFTWARE_mark\" id=\"0079068e-5b3f-4189-8fd3-5ef23b331dc9\">.<\/span><\/span>SFG_Event_21_22<br \/>\n<span class=\"GINGER_SOFTWARE_mark\" id=\"71b7de5d-f0da-4d2b-85a1-06303b624730\"><span class=\"GINGER_SOFTWARE_mark\" id=\"c7429a82-4351-43ea-af09-43930b4f4309\">from<\/span><\/span> &#8216;C:\\Users\\joemac\\Desktop\\final.csv&#8217;<br \/>\nWITH<br \/>\n(<br \/>\n<span class=\"GINGER_SOFTWARE_mark\" id=\"0198dc37-f203-48aa-a0a9-5bfd2c640895\"><span class=\"GINGER_SOFTWARE_mark\" id=\"6b223d18-13ce-4b70-8caa-556ebf2bfc4a\">firstrow<\/span><\/span> = 1,<br \/>\n<span class=\"GINGER_SOFTWARE_mark\" id=\"41e2c118-988b-47b6-b89d-c96147175f8e\"><span class=\"GINGER_SOFTWARE_mark\" id=\"b6f4addd-bbe1-4c42-bcd1-33674fdcda92\">fieldterminator<\/span><\/span> = &#8216;,&#8217;,<br \/>\n<span class=\"GINGER_SOFTWARE_mark\" id=\"0f2a7048-5eb9-4387-86e6-bf2a609e04df\"><span class=\"GINGER_SOFTWARE_mark\" id=\"9e95e234-e79b-4e95-a86b-b1915fa75e30\">rowterminator<\/span><\/span> = &#8216;0x0a&#8217;<br \/>\n);<br \/>\nGO<\/p>\n<ul>\n<li><span class=\"GINGER_SOFTWARE_mark\" id=\"604dc1d4-6c3a-43a9-b35f-afdf899ccfec\"><span class=\"GINGER_SOFTWARE_mark\" id=\"661bb3d7-e586-4358-9338-9e5a13f2da9d\">bulk<\/span><\/span> insert cannot understand text qualifier<\/li>\n<li><span class=\"GINGER_SOFTWARE_mark\" id=\"2a1ec9cb-e710-409d-a6f9-f659d4088a63\">bulk<\/span> insert <span class=\"GINGER_SOFTWARE_mark\" id=\"874423a1-e7da-482d-b996-a64e98a53928\">add<\/span> NULL for blank data by default<\/li>\n<\/ul>\n<p>Replace string value of a column<\/p>\n<p style=\"padding-left: 30px;\">UPDATE <span class=\"GINGER_SOFTWARE_mark\" id=\"82c69b22-181c-4155-a45a-14c66146e9c4\">dbo<\/span><span class=\"GINGER_SOFTWARE_mark\" id=\"fb88cb91-1852-439a-b715-571847d25edd\">.<\/span>SFG_Event_ResultFromApp<br \/>\nSET [17] = REPLACE<span class=\"GINGER_SOFTWARE_mark\" id=\"1fd9d3ba-5948-4ce3-b868-e20945c80531\">(<\/span>[17], &#8216;;&#8217;, &#8216;,&#8217;)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Extract table from another table SELECT * FROM dbo.SFG_Event_21_22 except SELECT * FROM dbo.SFG_Event_21 Bulk insert BULK insert dbo.SFG_Event_21_22 from &#8216;C:\\Users\\joemac\\Desktop\\final.csv&#8217; WITH ( firstrow = 1, fieldterminator = &#8216;,&#8217;, rowterminator = &#8216;0x0a&#8217; ); GO bulk insert cannot understand text qualifier bulk insert add NULL for blank data by default Replace string value of a column&hellip; <a class=\"more-link\" href=\"https:\/\/moneystock.net\/wp_e\/2014\/03\/23\/useful-command-of-mssql-query-when-comparing-and-manipulating-text-data\/\">Continue reading <span class=\"screen-reader-text\">Useful command of MSSQL Query when comparing and manipulating text data<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128],"tags":[],"class_list":["post-821","post","type-post","status-publish","format-standard","hentry","category-db","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/comments?post=821"}],"version-history":[{"count":3,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/821\/revisions"}],"predecessor-version":[{"id":823,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/821\/revisions\/823"}],"wp:attachment":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/media?parent=821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/categories?post=821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/tags?post=821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}