{"id":2507,"date":"2014-07-28T11:00:52","date_gmt":"2014-07-28T15:00:52","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=2507"},"modified":"2014-11-13T12:18:27","modified_gmt":"2014-11-13T17:18:27","slug":"temporary-symmetric-key-scope","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/","title":{"rendered":"The Unexpected Scope of Temporary Symmetric Keys"},"content":{"rendered":"<div>\n<p>\nJust as we can create temporary tables, SQL Server allows us to create <a href=\"http:\/\/sqlity.net\/en\/2500\/temporary-symmetric-key\/\">temporary symmetric keys<\/a>. Those temporary keys are only accessible from the session that created them and they are removed automatically when the session is closed. They seem to behave just like temporary tables, so you would expect to see the same scoping behavior too. Well, you might be in for a surprise.\n<\/p>\n<h3>Session Scope of Temporary Symmetric Keys<\/h3>\n<p>\nLet us start out by confirming that a temporary symmetric key is really only accessible within the current session. For that, we first need to create a brand new temporary symmetric key:\n<\/p>\n<div>\n[sql]\nCREATE SYMMETRIC KEY #temp<br \/>\n  WITH KEY_SOURCE = '%%%%%%%%%%',<br \/>\n       IDENTITY_VALUE = '2',<br \/>\n       ALGORITHM = AES_256<br \/>\n  ENCRYPTION BY PASSWORD='**********';<br \/>\nGO<br \/>\nSELECT SK.symmetric_key_id,SK.name,SK.key_guid FROM tempdb.sys.symmetric_keys AS SK WHERE SK.name LIKE '%temp%';<br \/>\n[\/sql]\n<\/div>\n<p>\nThis script consists of two statements. The first creates the temporary key. The second is a <span class=\"tt\">SELECT<\/span> against the <a href=\"http:\/\/sqlity.net\/en\/2443\/sys-symmetric_keys\/\"><span class=\"tt\">sys.symmetric_keys<\/span> catalog view<\/a> in <span class=\"tt\">tempdb<\/span> to prove that the key indeed was created. Executing this script will yield a result similar to this:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/a_simple_temporary_symmetric_key.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/a_simple_temporary_symmetric_key.jpg\" alt=\"a simple temporary symmetric key\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2512\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/a_simple_temporary_symmetric_key.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/a_simple_temporary_symmetric_key-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/a_simple_temporary_symmetric_key-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nNote that the SPID of the connection is <span class=\"tt\">51<\/span>.\n<\/p>\n<p>\nNow, let us try to use that key from another session. The following few lines attempt to encrypt a string with this key and then decrypt it again:\n<\/p>\n<div>\n[sql]\nOPEN SYMMETRIC KEY #temp DECRYPTION BY PASSWORD='**********'<br \/>\nDECLARE @cipher VARBINARY(MAX) = ENCRYPTBYKEY(KEY_GUID('#temp'),'Hello World!');<br \/>\nSELECT CAST(DECRYPTBYKEY(@cipher) AS VARCHAR(MAX)) AS [decrypted];<br \/>\n[\/sql]\n<\/div>\n<p>\nAs we expected, this does not work:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_not_usable_from_other_session.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_not_usable_from_other_session.jpg\" alt=\"temporary symmetric keys are only usable within the same session\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2509\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_not_usable_from_other_session.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_not_usable_from_other_session-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_not_usable_from_other_session-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nThis proves that a temporary symmetric key is only accessible in the same session that created the key.\n<\/p>\n<p>\nIt also means that the key should be cleaned up automatically when the session is ended and the connection is closed. To show that, I am just going to disconnect and reconnect the query window and rerun the <span class=\"tt\">SELECT<\/span> against <span class=\"tt\">sys.symmetric_keys<\/span>:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/dropping_connection_drops_temporary_symmetric_key.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/dropping_connection_drops_temporary_symmetric_key.jpg\" alt=\"closing a connection automatically drops temporary symmetric keys\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2508\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/dropping_connection_drops_temporary_symmetric_key.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/dropping_connection_drops_temporary_symmetric_key-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/dropping_connection_drops_temporary_symmetric_key-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nYou can see that the SPID changed and that the temporary symmetric key is gone. So far, the temporary keys behave just like temporary tables. However, that is going to change in a moment.\n<\/p>\n<h3>The Call Stack Scope of Temporary Symmetric Keys<\/h3>\n<p>\nWith \"Call Stack Scope\", I am referencing the visibility of temporary objects when it comes to stored procedures and dynamic SQL. Remember that any temporary table that is created within a stored procedure, <a href=\"http:\/\/sqlity.net\/en\/1109\/temp-tables-scoping-eclipsing\/\">is not accessible anymore, once the procedure exits<\/a>. The same is true for temporary tables created within a batch of dynamic SQL. As soon as that batch finishes, those temporary tables are automatically dropped.\n<\/p>\n<p>\nTemporary symmetric keys are different.\n<\/p>\n<p>\nFirst, let us try to create a temporary symmetric key using dynamic SQL:\n<\/p>\n<div>\n[sql]\nEXEC('CREATE SYMMETRIC KEY #temp WITH KEY_SOURCE = ''%%%%%%%%%%'', IDENTITY_VALUE = ''1'', ALGORITHM = AES_256 ENCRYPTION BY PASSWORD=''**********'';');<br \/>\nGO<br \/>\nSELECT SK.symmetric_key_id,SK.name,SK.key_guid FROM tempdb.sys.symmetric_keys AS SK WHERE SK.name LIKE '%temp%';<br \/>\n[\/sql]\n<\/div>\n<p>\nThe dynamically executed SQL statement creates a new temporary symmetric key. The following <span class=\"tt\">SELECT<\/span> then queries the <span class=\"tt\">sys.symmetric_keys<\/span> catalog view to see if that key is still available. Based on the behavior of temporary tables we would expect the key to be gone at that time. Let us try:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg\" alt=\"temporary symmetric key survives dynamic SQL scope\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2510\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nThe key is still very much existing. So, while a temporary table created in a dynamic SQL batch is dropped automatically, once the batch finishes, a temporary symmetric key survives.\n<\/p>\n<p>\nBut what about procedures? Let us check:\n<\/p>\n<div>\n[sql]\nIF OBJECT_ID('dbo.CreateTempKey') IS NOT NULL DROP PROCEDURE dbo.CreateTempKey;<br \/>\nGO<br \/>\nCREATE PROCEDURE dbo.CreateTempKey<br \/>\nAS<br \/>\nCREATE SYMMETRIC KEY #temp WITH KEY_SOURCE = '%%%%%%%%%%', IDENTITY_VALUE = '1', ALGORITHM = AES_256 ENCRYPTION BY PASSWORD='**********';<br \/>\nGO<\/p>\n<p>IF(KEY_ID('#temp') IS NOT NULL)DROP SYMMETRIC KEY #temp;<br \/>\nGO<br \/>\nEXEC dbo.CreateTempKey<br \/>\nGO<br \/>\nSELECT SK.symmetric_key_id,SK.name,SK.key_guid FROM tempdb.sys.symmetric_keys AS SK WHERE SK.name LIKE '%temp%';<br \/>\n[\/sql]\n<\/p><\/div>\n<p>\nThe procedure <span class=\"tt\">dbo.CreateTempKey<\/span> is very simple. Its only function is to create a temporary symmetric key. The script above first creates that procedure and then calls it. After the procedure finishes, the same <span class=\"tt\">SELECT<\/span> we have encountered before is used to see if the key is still there or if it is gone. And again, the behavior is different than we are used to from temporary tables:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_procedure_scope.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_procedure_scope.jpg\" alt=\"temporary symmetric key survives stored procedure scope\" width=\"768\" height=\"468\" class=\"aligncenter size-full wp-image-2511\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_procedure_scope.jpg 768w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_procedure_scope-300x182.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_procedure_scope-150x91.jpg 150w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a>\n<\/p>\n<p>\nHere too the temporary symmetric key continues its existence after the procedure it was created in exits.\n<\/p>\n<h3>Summary<\/h3>\n<p>\nWhile there are similarities between the scoping behavior of temporary tables and temporary symmetric keys, there are also some differences. Particularly, temporary symmetric keys that were created within a dynamic SQL batch or a stored procedure will live on after the batch or procedure finishes.\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you think temporary symmetric keys and temporary tables have the same scope, you will be in for a surprise. Read on to discover the truth.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":2510,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[32,5,34,212],"tags":[15,140,141,213],"class_list":["post-2507","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cryptography","category-general","category-security","category-temporary-objects","tag-sql-server","tag-symmetric-key","tag-symmetric-key-encryption","tag-temporary-symmetric-key"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The Unexpected Scope of Temporary Symmetric Keys - sqlity.net<\/title>\n<meta name=\"description\" content=\"If you think temporary symmetric keys and temporary tables have the same scope, you will be in for a surprise. Read on to discover the truth.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Unexpected Scope of Temporary Symmetric Keys - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"If you think temporary symmetric keys and temporary tables have the same scope, you will be in for a surprise. Read on to discover the truth.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/\" \/>\n<meta property=\"og:site_name\" content=\"sqlity.net\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sqlity.net\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-28T15:00:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T17:18:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"768\" \/>\n\t<meta property=\"og:image:height\" content=\"468\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sebastian Meine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sqlity\" \/>\n<meta name=\"twitter:site\" content=\"@sqlity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sebastian Meine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"The Unexpected Scope of Temporary Symmetric Keys\",\"datePublished\":\"2014-07-28T15:00:52+00:00\",\"dateModified\":\"2014-11-13T17:18:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/\"},\"wordCount\":834,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/temporary_symmetric_key_survives_EXEC_scope.jpg\",\"keywords\":[\"SQL Server\",\"symmetric key\",\"symmetric key encryption\",\"temporary symmetric key\"],\"articleSection\":[\"Cryptography\",\"General\",\"Security\",\"Temporary Objects\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/\",\"name\":\"The Unexpected Scope of Temporary Symmetric Keys - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/temporary_symmetric_key_survives_EXEC_scope.jpg\",\"datePublished\":\"2014-07-28T15:00:52+00:00\",\"dateModified\":\"2014-11-13T17:18:27+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"If you think temporary symmetric keys and temporary tables have the same scope, you will be in for a surprise. Read on to discover the truth.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/temporary_symmetric_key_survives_EXEC_scope.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/07\\\/temporary_symmetric_key_survives_EXEC_scope.jpg\",\"width\":768,\"height\":468,\"caption\":\"temporary symmetric key survives dynamic SQL scope\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2507\\\/temporary-symmetric-key-scope\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Unexpected Scope of Temporary Symmetric Keys\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\",\"name\":\"sqlity.net\",\"description\":\"Quality for SQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sqlity.net\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\",\"name\":\"Sebastian Meine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"caption\":\"Sebastian Meine\"},\"sameAs\":[\"http:\\\/\\\/sqlity.net\",\"https:\\\/\\\/x.com\\\/sqlity\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Unexpected Scope of Temporary Symmetric Keys - sqlity.net","description":"If you think temporary symmetric keys and temporary tables have the same scope, you will be in for a surprise. Read on to discover the truth.","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:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/","og_locale":"en_US","og_type":"article","og_title":"The Unexpected Scope of Temporary Symmetric Keys - sqlity.net","og_description":"If you think temporary symmetric keys and temporary tables have the same scope, you will be in for a surprise. Read on to discover the truth.","og_url":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2014-07-28T15:00:52+00:00","article_modified_time":"2014-11-13T17:18:27+00:00","og_image":[{"width":768,"height":468,"url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg","type":"image\/jpeg"}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"The Unexpected Scope of Temporary Symmetric Keys","datePublished":"2014-07-28T15:00:52+00:00","dateModified":"2014-11-13T17:18:27+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/"},"wordCount":834,"commentCount":0,"image":{"@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg","keywords":["SQL Server","symmetric key","symmetric key encryption","temporary symmetric key"],"articleSection":["Cryptography","General","Security","Temporary Objects"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/","url":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/","name":"The Unexpected Scope of Temporary Symmetric Keys - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg","datePublished":"2014-07-28T15:00:52+00:00","dateModified":"2014-11-13T17:18:27+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"If you think temporary symmetric keys and temporary tables have the same scope, you will be in for a surprise. Read on to discover the truth.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#primaryimage","url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg","contentUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg","width":768,"height":468,"caption":"temporary symmetric key survives dynamic SQL scope"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/2507\/temporary-symmetric-key-scope\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"The Unexpected Scope of Temporary Symmetric Keys"}]},{"@type":"WebSite","@id":"https:\/\/sqlity.net\/en\/#website","url":"https:\/\/sqlity.net\/en\/","name":"sqlity.net","description":"Quality for SQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sqlity.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c","name":"Sebastian Meine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","caption":"Sebastian Meine"},"sameAs":["http:\/\/sqlity.net","https:\/\/x.com\/sqlity"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/07\/temporary_symmetric_key_survives_EXEC_scope.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-Er","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/comments?post=2507"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2507\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media\/2510"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=2507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=2507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=2507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}