{"id":762,"date":"2014-04-16T12:44:51","date_gmt":"2014-04-16T16:44:51","guid":{"rendered":"http:\/\/binary-world.com\/blogs\/?p=762"},"modified":"2015-12-01T16:37:37","modified_gmt":"2015-12-01T21:37:37","slug":"how-to-create-temp-table-on-pdw-parallel-data-warehouse","status":"publish","type":"post","link":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/","title":{"rendered":"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse)"},"content":{"rendered":"<p>Microsoft PDW (Parallel Data Warehouse) is a special version of SQL Server which is specifically design to scale for massive amount of data (upto several petabytes). PDW can not be downloaded like regular SQL server because it comes as pre-packaged Hardware with Software installed. PDW can you SQL Server Like familiar environment but it comes with its own limitations too compared to regular SQL Server Editions (e.g. Standard\/Enterprise)<\/p>\n<p>One of the most common task user often do while writing t-sql is create static or temp tables. With PDW its has some syntax changes. Here are few <strong>facts about creating temp tables on PDW<\/strong><\/p>\n<ul>\n<li>Global Temp tables not supported in PDW<\/li>\n<li>When creating TEMP Table you must specify LOCATION=USER_DB<\/li>\n<li>Creating NON CLUSTERED index not supported on temp table in PDW<\/li>\n<\/ul>\n<p>Below is simple script <strong>how to create Temp Table on PDW<\/strong>. One thing to notice on that is use of LOCATION=USER_DB. This is required for creating temp table. But not required for creating static table.<\/p>\n<h2>Create and query Temp Table on PDW<\/h2>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">use tempdb;\r\n\r\nCREATE TABLE #TableA(\r\n   yearId int NOT NULL,\r\n   some1 varchar(50),\r\n   stuff1 varchar(50))\r\nWITH (LOCATION = USER_DB) --NOTE: must include LOCATION=USER_DB\r\ninsert into #TableA(yearid,some1,stuff1) values (2000,&#039;aaa&#039;,&#039;bbb&#039;)\r\ninsert into #TableA(yearid,some1,stuff1) values (2001,&#039;xxx&#039;,&#039;yyy&#039;)\r\n<\/pre>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">CREATE CLUSTERED INDEX IX_yearID ON #TableA(yearId); --NOTE: NON CLUSTERED INDEX not supported with temp table<\/pre>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">select * from #TableA where yearId=2001;\r\n\r\ngo<\/pre>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">drop table #TableA;<\/pre>\n<h2>Create and query Static Table on PDW<\/h2>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">CREATE TABLE TableA(\r\n   yearId int NOT NULL,\r\n   some1 varchar(50),\r\n   stuff1 varchar(50))\r\n\r\ninsert into TableA(yearid,some1,stuff1) values (2000,&#039;aaa&#039;,&#039;bbb&#039;)\r\ninsert into TableA(yearid,some1,stuff1) values (2001,&#039;xxx&#039;,&#039;yyy&#039;)<\/pre>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">CREATE NON CLUSTERED INDEX IX_yearID ON TableA(yearId); --\/\/CLUSTERED or NON CLUSTERED<\/pre>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">select * from TableA where yearId=2001;\r\n\r\ngo<\/pre>\n<p>Here is the official syntax of create table command (SQL 2012 PDW)<\/p>\n<pre class=\"brush: text; gutter: true; first-line: 1\">******** Create a new static table ********\r\nCREATE TABLE [ database_name . [ dbo ] . | dbo. ] table_name \r\n    ( \r\n        { column_name &lt;data_type&gt; \r\n        [ COLLATE Windows_collation_name ]\r\n        [ NULL | NOT NULL ] \r\n        [ [ CONSTRAINT constraint_name ] DEFAULT constant_expression  ] }\r\n        [ ,...n ] \r\n    )\r\n    [ WITH ( &lt;table_option&gt; [ ,...n ] ) ]\r\n[;]\r\n\r\n******** Create a new temporary table ********\r\nCREATE TABLE [ database_name . [ dbo ] . | dbo. ] #table_name \r\n    ( \r\n        { column_name &lt;data_type&gt; \r\n        [ COLLATE Windows_collation_name ]\r\n        [ NULL | NOT NULL ] } \r\n        [ ,...n ] \r\n    )\r\n    WITH ( LOCATION = USER_DB [, &lt;table_option&gt; [ ,...n ] ] )  \r\n[;]\r\n\r\n\r\n&lt;table_option&gt; ::=\r\n    CLUSTERED COLUMNSTORE INDEX\r\n    | CLUSTERED INDEX ( { index_column_name [ ASC | DESC ] } [ ,...n ] ) \r\n    | DISTRIBUTION = { HASH ( distribution_column_name ) | REPLICATE } \r\n    | PARTITION ( partition_column_name RANGE [ LEFT | RIGHT ]\r\n        FOR VALUES ( [ boundary_value [,...n] ] ) )\r\n\r\n\r\n&lt;data type&gt; ::= \r\n    datetimeoffset [ ( n ) ]\r\n    | datetime2 [ ( n ) ]\r\n    | datetime\r\n    | smalldatetime\r\n    | date\r\n    | time [ ( n ) ]\r\n    | float [ ( n ) ]\r\n    | real [ ( n ) ]\r\n    | decimal [ ( precision [ , scale ] ) ] \r\n    | money\r\n    | smallmoney\r\n    | bigint\r\n    | int \r\n    | smallint\r\n    | tinyint\r\n    | bit\r\n    | nvarchar [ ( n ) ]\r\n    | nchar [ ( n ) ]\r\n    | varchar [ ( n ) ]\r\n    | char [ ( n ) ]\r\n    | varbinary [ ( n ) ]\r\n    | binary [ ( n ) ]<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft PDW (Parallel Data Warehouse) is a special version of SQL Server which is specifically design to scale for massive amount of data (upto several petabytes). PDW can not be downloaded like regular SQL server because it comes as pre-packaged &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/\"> <span class=\"screen-reader-text\">How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse)<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":773,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[126],"tags":[165,124,123,158],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) - BinaryWorld Blog<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) - BinaryWorld Blog\" \/>\r\n<meta property=\"og:description\" content=\"Microsoft PDW (Parallel Data Warehouse) is a special version of SQL Server which is specifically design to scale for massive amount of data (upto several petabytes). PDW can not be downloaded like regular SQL server because it comes as pre-packaged &hellip; How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) Read More &raquo;\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/\" \/>\r\n<meta property=\"og:site_name\" content=\"BinaryWorld Blog\" \/>\r\n<meta property=\"article:published_time\" content=\"2014-04-16T16:44:51+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2015-12-01T21:37:37+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg\" \/>\r\n\t<meta property=\"og:image:width\" content=\"150\" \/>\r\n\t<meta property=\"og:image:height\" content=\"150\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\r\n<meta name=\"author\" content=\"Binary World\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Binary World\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/\",\"url\":\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/\",\"name\":\"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) - BinaryWorld Blog\",\"isPartOf\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg\",\"datePublished\":\"2014-04-16T16:44:51+00:00\",\"dateModified\":\"2015-12-01T21:37:37+00:00\",\"author\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0\"},\"breadcrumb\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#primaryimage\",\"url\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg\",\"contentUrl\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Sql ServerParallel Data Warehouse (PDW)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/binaryworld.net\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#website\",\"url\":\"https:\/\/binaryworld.net\/blogs\/\",\"name\":\"BinaryWorld Blog\",\"description\":\"Tips and Tutorials for Microsoft SQL Server, SSIS, SSAS, Business Intelligence, C#, .net\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/binaryworld.net\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0\",\"name\":\"Binary World\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g\",\"caption\":\"Binary World\"},\"description\":\"Binary World is a Software Development company located in Atlanta, USA (since 2007). Binary World specialized in Business Intelligence, mobile, cloud computing and .Net Application Development.\",\"url\":\"https:\/\/binaryworld.net\/blogs\/author\/admin\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) - BinaryWorld Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) - BinaryWorld Blog","og_description":"Microsoft PDW (Parallel Data Warehouse) is a special version of SQL Server which is specifically design to scale for massive amount of data (upto several petabytes). PDW can not be downloaded like regular SQL server because it comes as pre-packaged &hellip; How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) Read More &raquo;","og_url":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/","og_site_name":"BinaryWorld Blog","article_published_time":"2014-04-16T16:44:51+00:00","article_modified_time":"2015-12-01T21:37:37+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg","type":"image\/jpeg"}],"author":"Binary World","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Binary World","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/","url":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/","name":"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse) - BinaryWorld Blog","isPartOf":{"@id":"https:\/\/binaryworld.net\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#primaryimage"},"image":{"@id":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#primaryimage"},"thumbnailUrl":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg","datePublished":"2014-04-16T16:44:51+00:00","dateModified":"2015-12-01T21:37:37+00:00","author":{"@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0"},"breadcrumb":{"@id":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#primaryimage","url":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg","contentUrl":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/04\/sql-server-pdw-parallel-data-warehouse-logo.jpg","width":150,"height":150,"caption":"Sql ServerParallel Data Warehouse (PDW)"},{"@type":"BreadcrumbList","@id":"https:\/\/binaryworld.net\/blogs\/how-to-create-temp-table-on-pdw-parallel-data-warehouse\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/binaryworld.net\/blogs\/"},{"@type":"ListItem","position":2,"name":"How to Create Static \/ Temp Table on PDW (Parallel Data Warehouse)"}]},{"@type":"WebSite","@id":"https:\/\/binaryworld.net\/blogs\/#website","url":"https:\/\/binaryworld.net\/blogs\/","name":"BinaryWorld Blog","description":"Tips and Tutorials for Microsoft SQL Server, SSIS, SSAS, Business Intelligence, C#, .net","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/binaryworld.net\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0","name":"Binary World","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g","caption":"Binary World"},"description":"Binary World is a Software Development company located in Atlanta, USA (since 2007). Binary World specialized in Business Intelligence, mobile, cloud computing and .Net Application Development.","url":"https:\/\/binaryworld.net\/blogs\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts\/762"}],"collection":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/comments?post=762"}],"version-history":[{"count":0,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts\/762\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/media\/773"}],"wp:attachment":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/media?parent=762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/categories?post=762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/tags?post=762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}