{"id":67,"date":"2009-04-28T13:43:14","date_gmt":"2009-04-28T13:43:14","guid":{"rendered":"http:\/\/muratyaman.co.uk\/wp\/?p=67"},"modified":"2020-04-01T13:06:52","modified_gmt":"2020-04-01T12:06:52","slug":"ms-sql-server-temporary-tables","status":"publish","type":"post","link":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/2009\/04\/ms-sql-server-temporary-tables\/","title":{"rendered":"MS SQL Server: Temporary Tables"},"content":{"rendered":"<p>Just a way of using temporary tables in Microsoft SQL Server, if you want to duplicate one or more records quickly, you can use commands like this:<\/p>\n<pre lang=\"sql\">\r\n\r\nSELECT *\r\nINTO #temporary\r\nFROM table1\r\nWHERE idfield=1; --create similar table by selecting a record\r\nGO\r\n\r\nUPDATE #temporary\r\nSET idfield=2; -- change primary key value\r\n-- otherwise, we cannot insert into source table1\r\nGO\r\n\r\nINSERT INTO table1\r\nSELECT * FROM #temporary;\r\nGO\r\n<\/pre>\n<p>This is much shorter if you have 50 fields in your source table. Otherwise, you have to specify each field and their data types;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just a way of using temporary tables in Microsoft SQL Server, if you want to duplicate one or more records quickly, you can use commands like this&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[56,33],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-technology","tag-ms-sql-server","tag-sql"],"_links":{"self":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":8,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":1006,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions\/1006"}],"wp:attachment":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}