{"id":197,"date":"2012-05-11T12:25:42","date_gmt":"2012-05-11T12:25:42","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/05\/11\/msg-214-level-16-state-2-procedure-sp_executesql-line-1\/"},"modified":"2012-05-11T12:25:42","modified_gmt":"2012-05-11T12:25:42","slug":"msg-214-level-16-state-2-procedure-sp_executesql-line-1","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/05\/11\/msg-214-level-16-state-2-procedure-sp_executesql-line-1\/","title":{"rendered":"Msg 214, Level 16, State 2, Procedure sp_executesql, Line 1"},"content":{"rendered":"

When you try to execute sp_executesql you get the below error:<\/p>\n


\nMsg 214, Level 16, State 2, Procedure sp_executesql, Line 1
\nProcedure expects parameter ‘@statement’ of type ‘ntext\/nchar\/nvarchar’.
\n<\/font><\/p>\n

Fix:<\/strong>
\nAdd N Before the sql query.<\/p>\n

Before:
\n[sql]
\nEXEC sp_executesql ‘SELECT 1′
\n[\/sql]<\/p>\n

After:
\n[sql]
\nEXEC sp_executesql N’SELECT 1’
\n[\/sql]<\/p>\n

Applies to SQL Server 2000,SQL Server 2005,SQL Server 2008,SQL Server 2008 r2,SQL Server 2012, SSIS<\/p>\n","protected":false},"excerpt":{"rendered":"

When you try to execute sp_executesql you get the below error: Msg 214, Level 16, State 2, Procedure sp_executesql, Line 1 Procedure expects parameter ‘@statement’ of type ‘ntext\/nchar\/nvarchar’. Fix: Add N Before the sql query. Before: [sql] EXEC sp_executesql ‘SELECT 1′ [\/sql] After: [sql] EXEC sp_executesql N’SELECT 1’ [\/sql] Applies to SQL Server 2000,SQL Server…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1925,128,1926],"tags":[1927,1928],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/197"}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}