title: How to identify that Dynamic Sql fail?
body: <p>I have created a trigger and inside it, there's dynamic SQL gets executed.</p>
  
  <p>Here is sample script:</p>
  
  <p>When I specifying <code>@Text</code> to some value,it work (after exec showing 1 row affetected)but when I am specifying null,
  record not get added into table(Message:query executed sucessfully).I want like like his,if record not get added into sample table,pls add into Sample 2 without dynamic insertion.How to find out dynamic exec successfully or not.I don't want fetch last identity of table.How to do that?</p>
  
  <pre><code>declare @Inserttbl nvarchar(4000)
  declare @TableName varchar(50)
  declare @PId int
  declare @Text varchar(50)
  declare @count int
  declare @Status int
  set @TableName ='sample'
  set @Text = null
  set @PId  = 3
  set @Status =1
  
  set @Inserttbl = ' Insert into Test.dbo.' +@TableName +' values ('+@PId+','+@Text+','+@Status+')'
  exec sp_executesql @Inserttbl
  </code></pre>