Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

error converting data type nvarchar to int

$
0
0

Hi here is the below stored procedure and when i pass the single value to the @getValue parameter it is not giving any error but when i select multiple values it is resulting the error as it is showing in the title

ALTER PROCEDURE [dbo].[spGetValues]
(
  @getValue int = 100
 ,@userId     varchar(200) = null 
)
AS

declare @runTime                 as datetime = getutcdate()
declare @rowCnt                   as int

select
   csk    
  , ccode 
  , cdesc  
from
 dbo.code
where
  ctype =  'status_csk'
  and csortnum >= case  @getValue
                       when 100 then 0
                       when 101 then 10000
                       when 102 then 100000
                     end 
  and csortnum <  case  @getValue
                       when 100 then 10000
                       when 101 then 100000
                       when 102 then 200000
                     end 
order by
  csortnum

--=======================================================
--=======================================================
set @rowCnt = @@ROWCOUNT  
insert into dbo.report
(
  rname
, rincrement
, rdate
, ruserid
, rurl
, rsecs
, rscnt
, rparm1
, rparm2
)
values
(
  OBJECT_NAME(@@PROCID)
, 0
, GETUTCDATE()
, SUSER_NAME()
, null
, DATEDIFF(S,@runTime  ,GETUTCDATE())       
, @rowCnt
, 'RptUser:' + isnull(@userId , '')
, 'TcType: ' + cast(@getValue as varchar(6))
)

so if anyone knows what's the problem please let me know.


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>