{"id":1301,"date":"2011-02-01T09:01:27","date_gmt":"2011-02-01T16:01:27","guid":{"rendered":"http:\/\/juixe.com\/techknow\/?p=1301"},"modified":"2011-01-30T14:01:23","modified_gmt":"2011-01-30T21:01:23","slug":"copy-data-between-two-database-tables","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2011\/02\/01\/copy-data-between-two-database-tables\/","title":{"rendered":"Copy Data Between Two Database Tables"},"content":{"rendered":"<p>There are many situations when you need to copy data from one database table to another one.  You may want to migrate data from one database table to a new table, sometimes you need to do so to copy data to a backup table, other times to bulk load data from from different databases.  To copy date between tables in a SQL Server database you can execute the following.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nINSERT INTO Note (Id, Name)\r\nSELECT Id, Name FROM Notes\r\nWHERE name IS NOT NULL\r\n<\/pre>\n<p>The above state will copy date from a database table Notes to a new table Note where some condition is meet.  <\/p>\n<p>A typical database server instance hosts multiple databases, such as production and several test databases.  You can copy data not only between tables within a database, but between databases within a database server instance.  To copy between databases you need to use the fully qualified database name.  For example, the following SQL snippet copies data from a tables called Notes in a database called TestDB.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nINSERT INTO Note (Id, Name)\r\nSELECT Id, Name FROM TestDB.dbo.Notes\r\nWHERE name IS NOT NULL\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are many situations when you need to copy data from one database table to another one. You may want to migrate data from one database table to a new table, sometimes you need to do so to copy data to a backup table, other times to bulk load data from from different databases. To [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[23,3],"tags":[414,416,270,415,807,417],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-kZ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1301"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=1301"}],"version-history":[{"count":1,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1301\/revisions"}],"predecessor-version":[{"id":1302,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1301\/revisions\/1302"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=1301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=1301"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=1301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}