{"id":1795,"date":"2014-01-11T11:00:08","date_gmt":"2014-01-11T16:00:08","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=1795"},"modified":"2014-11-13T13:21:38","modified_gmt":"2014-11-13T18:21:38","slug":"mystery-suser_name-suser_sname-functions","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/","title":{"rendered":"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions"},"content":{"rendered":"<div>\n<h3>Introduction<\/h3>\n<p>\nSQL Server has two functions to return the name of the current login: <span class=\"tt\">SUSER_NAME()<\/span> and <span class=\"tt\">SUSER_SNAME()<\/span>. So, you might ask, why are there two functions that do the same thing?\n<\/p>\n<p>\nWell, they are not completely alike. To figure out the difference, let's see them in action first.\n<\/p>\n<h3>A Simple SUSER_NAME() vs. SUSER_NAME() Example<\/h3>\n<p>\nFirst we need a few principals to play with:\n<\/p>\n<div>\n[sql]\nCREATE LOGIN TestLogin1 WITH PASSWORD='********', CHECK_POLICY = OFF;<br \/>\nCREATE USER TestUser1 FOR LOGIN TestLogin1;<br \/>\nCREATE SERVER ROLE TestRole1 AUTHORIZATION TestLogin1;<br \/>\n[\/sql]\n<\/div>\n<p>\nNow we can log in as TestLogin1 and run this <span class=\"tt\">SELECT<\/span> statement:\n<\/p>\n<div>\n[sql]\nSELECT SUSER_NAME() AS [SUSER_NAME()], SUSER_SNAME() AS [SUSER_SNAME()];<br \/>\n[\/sql]\n<\/div>\n<p>\nAs expected, both functions return the exact same value:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg\" alt=\"SUSER_NAME() vs SUSER_SNAME()\" width=\"742\" height=\"444\" class=\"aligncenter size-full wp-image-1798\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg 742w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME-300x179.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME-150x89.jpg 150w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/a>\n<\/p>\n<p>\nThe difference lies in the parameter. Both functions take a single optional parameter. If the parameter is supplied, the name of the server_principal that that parameter is pointing at is returned instead of the name of the current login. <span class=\"tt\">SUSER_NAME()<\/span> takes the <span class=\"tt\">principal_id<\/span> of the server principal, whereas <span class=\"tt\">SUSER_SNAME()<\/span> takes the <span class=\"tt\">SID<\/span>:\n<\/p>\n<div>\n[sql]\nSELECT  SP.name,<br \/>\n        SUSER_NAME(SP.principal_id) AS [SUSER_NAME(SP.principal_id)],<br \/>\n        SUSER_SNAME(SP.sid) AS [SUSER_SNAME(SP.sid)]\nFROM    sys.server_principals AS SP<br \/>\nWHERE   SP.name = 'TestLogin1';<br \/>\n[\/sql]\n<\/div>\n<p>\nThis statement calls both functions with their respective correct parameters. The result looks like this, independent of the account you used to login:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_and_SUSER_SNAME_with_parameters.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_and_SUSER_SNAME_with_parameters.jpg\" alt=\"SUSER_NAME() and SUSER_SNAME() with Parameters\" width=\"742\" height=\"444\" class=\"aligncenter size-full wp-image-1796\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_and_SUSER_SNAME_with_parameters.jpg 742w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_and_SUSER_SNAME_with_parameters-300x179.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_and_SUSER_SNAME_with_parameters-150x89.jpg 150w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/a>\n<\/p>\n<p>So, which function you need to use, depends on what type of information you have about the server principal whose name you want to look up.\n<\/p>\n<h3>A SUSER_NAME() Use Case<\/h3>\n<p>\nIf you for example want to look up the name of the principal owning a server role, you have to use the <span class=\"tt\">SUSER_NAME()<\/span> function because the information about the owner is provided as a principal id in the <span class=\"tt\">owning_principal_id<\/span> column:\n<\/p>\n<div>\n[sql]\nSELECT  SP.name,<br \/>\n        SP.owning_principal_id,<br \/>\n        SUSER_NAME(SP.owning_principal_id) AS owning_principal_name<br \/>\nFROM    sys.server_principals AS SP<br \/>\nWHERE   SP.name = 'TestRole1';<br \/>\n[\/sql]\n<\/div>\n<p>\nBecause we specified <span class=\"tt\">AUTHORIZATION TestLogin1<\/span> when we created the role, <span class=\"tt\">TestRole1<\/span> is owned by <span class=\"tt\">TestLogin1<\/span> and that is what above query returns:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_in_action.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_in_action.jpg\" alt=\"SUSER_NAME() in Action\" width=\"742\" height=\"444\" class=\"aligncenter size-full wp-image-1797\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_in_action.jpg 742w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_in_action-300x179.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_in_action-150x89.jpg 150w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/a>\n<\/p>\n<h3>A SUSER_SNAME() Use Case<\/h3>\n<p>\nIf you want to look up the name of the associated login for a given user, you can either join the <span class=\"tt\">sys.database_principals<\/span> table to the <span class=\"tt\">sys.server_principals<\/span> table as shown in <a href=\"http:\/\/sqlity.net\/en\/1755\/sql-server-database-users-sys-database_principals-catalog-view\/\">SQL Server Database Users and the sys.database_principals catalog view<\/a>, or you can call <span class=\"tt\">SUSER_SNAME()<\/span> passing in the <span class=\"tt\">SID<\/span> value from the <span class=\"tt\">sys.database_principals<\/span> table like this:\n<\/p>\n<div>\n[sql]\nSELECT  DP.name,<br \/>\n        DP.SID,<br \/>\n        SUSER_SNAME(DP.sid) AS [SUSER_SNAME(DP.sid)]\nFROM    sys.database_principals AS DP<br \/>\nWHERE   DP.name = 'TestUser1';<br \/>\n[\/sql]\n<\/div>\n<p>\nThe <span class=\"tt\">TestUser1<\/span> user was created from the login <span class=\"tt\">TestLogin1<\/span>, so we expect that name to be returned. And it is:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_SNAME_in_action.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_SNAME_in_action.jpg\" alt=\"SUSER_SNAME() in Action\" width=\"742\" height=\"444\" class=\"aligncenter size-full wp-image-1799\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_SNAME_in_action.jpg 742w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_SNAME_in_action-300x179.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_SNAME_in_action-150x89.jpg 150w\" sizes=\"auto, (max-width: 742px) 100vw, 742px\" \/><\/a>\n<\/p>\n<\/p>\n<h3>Summary<\/h3>\n<p>\n<span class=\"tt\">SUSER_NAME()<\/span> and <span class=\"tt\">SUSER_SNAME()<\/span> both return the name of the current login when called without parameter. Their different strengths are revealed when they are called passing in a value identifying the server principal. The former takes the principal id as input whereas the latter takes the SID.\n<\/p>\n<p>\nIf you followed along with the examples, run the following statements to remove the test principals.\n<\/p>\n<div>\n[sql]\nDROP SERVER ROLE TestRole1;<br \/>\nDROP USER TestUser1;<br \/>\nDROP LOGIN TestLogin1;<br \/>\n[\/sql]\n<\/div>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The SQL Server functions SUSER_NAME() and SUSER_SNAME() both return the current login name. So why are there two? Read on to find out what the difference is.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_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},"jetpack_post_was_ever_published":false},"categories":[29,5,34],"tags":[50,38,58,51,55,15],"class_list":["post-1795","post","type-post","status-publish","format-standard","hentry","category-fundamentals","category-general","category-security","tag-permission","tag-security-2","tag-security-management","tag-security-tokens","tag-server-roles","tag-sql-server"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The Mystery of the SUSER_NAME() and SUSER_SNAME() functions - sqlity.net<\/title>\n<meta name=\"description\" content=\"The SQL Server functions SUSER_NAME() and SUSER_SNAME() both return the current login name. So why are there two? Read on to find out what the difference is.\" \/>\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\/1795\/mystery-suser_name-suser_sname-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"The SQL Server functions SUSER_NAME() and SUSER_SNAME() both return the current login name. So why are there two? Read on to find out what the difference is.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/\" \/>\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-01-11T16:00:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T18:21:38+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions\",\"datePublished\":\"2014-01-11T16:00:08+00:00\",\"dateModified\":\"2014-11-13T18:21:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/\"},\"wordCount\":611,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/SUSER_NAME_vs_SUSER_SNAME.jpg\",\"keywords\":[\"Permission\",\"security\",\"security management\",\"Security Tokens\",\"server roles\",\"SQL Server\"],\"articleSection\":[\"Fundamentals\",\"General\",\"Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/\",\"name\":\"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/SUSER_NAME_vs_SUSER_SNAME.jpg\",\"datePublished\":\"2014-01-11T16:00:08+00:00\",\"dateModified\":\"2014-11-13T18:21:38+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"The SQL Server functions SUSER_NAME() and SUSER_SNAME() both return the current login name. So why are there two? Read on to find out what the difference is.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#primaryimage\",\"url\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/SUSER_NAME_vs_SUSER_SNAME.jpg\",\"contentUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/SUSER_NAME_vs_SUSER_SNAME.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1795\\\/mystery-suser_name-suser_sname-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions\"}]},{\"@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 Mystery of the SUSER_NAME() and SUSER_SNAME() functions - sqlity.net","description":"The SQL Server functions SUSER_NAME() and SUSER_SNAME() both return the current login name. So why are there two? Read on to find out what the difference is.","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\/1795\/mystery-suser_name-suser_sname-functions\/","og_locale":"en_US","og_type":"article","og_title":"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions - sqlity.net","og_description":"The SQL Server functions SUSER_NAME() and SUSER_SNAME() both return the current login name. So why are there two? Read on to find out what the difference is.","og_url":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2014-01-11T16:00:08+00:00","article_modified_time":"2014-11-13T18:21:38+00:00","og_image":[{"url":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg","type":"","width":"","height":""}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions","datePublished":"2014-01-11T16:00:08+00:00","dateModified":"2014-11-13T18:21:38+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/"},"wordCount":611,"commentCount":1,"image":{"@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg","keywords":["Permission","security","security management","Security Tokens","server roles","SQL Server"],"articleSection":["Fundamentals","General","Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/","url":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/","name":"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg","datePublished":"2014-01-11T16:00:08+00:00","dateModified":"2014-11-13T18:21:38+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"The SQL Server functions SUSER_NAME() and SUSER_SNAME() both return the current login name. So why are there two? Read on to find out what the difference is.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#primaryimage","url":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg","contentUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/01\/SUSER_NAME_vs_SUSER_SNAME.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/1795\/mystery-suser_name-suser_sname-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"The Mystery of the SUSER_NAME() and SUSER_SNAME() functions"}]},{"@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_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-sX","jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1795","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=1795"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1795\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=1795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=1795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=1795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}