Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Store Procedure

Store Procedure

Scheduled Pinned Locked Moved Database
sharepointhelpannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brettokumar
    wrote on last edited by
    #1

    hi i am using a store procedure for passing number of value and using two parameter one is value and another one is id use to update table my store procedure like below coding but this store procedure is created but when i am execute this sp it display error like this : Conversion failed when converting the varchar value '1,2,7,8,12' to data type int. my coding is like: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER procedure [dbo].[sp_txtSplit_Summa1](@sp_Visible varchar(1000), @sp_CRID Varchar(100), @sp_Delimiter char(1)=',') as begin set nocount on declare @Item varchar(1000) declare @ItemID varchar(100) while (charIndex(@sp_Delimiter,@sp_Visible,0)<>0 and charIndex(@sp_CRID,@sp_Visible,0)<>0) begin select @Item= rtrim(ltrim(substring(@sp_Visible,1,CharIndex(@sp_Delimiter,@sp_Visible,0)-1))), @ItemID=rtrim(ltrim(substring(@sp_CRID,1,CharIndex(@sp_Delimiter,@sp_CRID,0)-1))), @sp_Visible=rtrim(ltrim(substring(@sp_visible,charindex(@sp_delimiter,@sp_Visible,0)+1,len(@sp_Visible)))), @sp_CRID=rtrim(ltrim(substring(@sp_visible,charindex(@sp_delimiter,@sp_CRID,0)+1,len(@sp_CRID)))) if len(@Item)>0 select (@item) select (@ItemID) update summa1 set age= (select @Item ) where sno= (select @ItemID ) end if len(@sp_Visible)>0 update summa1 set age= (select @sp_Visible) where sno= (select@sp_CRID) select (@item) select (@ItemID) select * from summa1 return end --CAST(CAST(@myval AS varbinary(20)) AS decimal(10,5)) exec sp_txtSplit_Summa1 '21,22,333,444,555','1,2,7,8,12',','

    with regards, bretto

    S 1 Reply Last reply
    0
    • B brettokumar

      hi i am using a store procedure for passing number of value and using two parameter one is value and another one is id use to update table my store procedure like below coding but this store procedure is created but when i am execute this sp it display error like this : Conversion failed when converting the varchar value '1,2,7,8,12' to data type int. my coding is like: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER procedure [dbo].[sp_txtSplit_Summa1](@sp_Visible varchar(1000), @sp_CRID Varchar(100), @sp_Delimiter char(1)=',') as begin set nocount on declare @Item varchar(1000) declare @ItemID varchar(100) while (charIndex(@sp_Delimiter,@sp_Visible,0)<>0 and charIndex(@sp_CRID,@sp_Visible,0)<>0) begin select @Item= rtrim(ltrim(substring(@sp_Visible,1,CharIndex(@sp_Delimiter,@sp_Visible,0)-1))), @ItemID=rtrim(ltrim(substring(@sp_CRID,1,CharIndex(@sp_Delimiter,@sp_CRID,0)-1))), @sp_Visible=rtrim(ltrim(substring(@sp_visible,charindex(@sp_delimiter,@sp_Visible,0)+1,len(@sp_Visible)))), @sp_CRID=rtrim(ltrim(substring(@sp_visible,charindex(@sp_delimiter,@sp_CRID,0)+1,len(@sp_CRID)))) if len(@Item)>0 select (@item) select (@ItemID) update summa1 set age= (select @Item ) where sno= (select @ItemID ) end if len(@sp_Visible)>0 update summa1 set age= (select @sp_Visible) where sno= (select@sp_CRID) select (@item) select (@ItemID) select * from summa1 return end --CAST(CAST(@myval AS varbinary(20)) AS decimal(10,5)) exec sp_txtSplit_Summa1 '21,22,333,444,555','1,2,7,8,12',','

      with regards, bretto

      S Offline
      S Offline
      SomeGuyThatIsMe
      wrote on last edited by
      #2

      the problem is in the second update if i'm reading this correctly, @sp_CRID is a comma delimited list if integers which must be treated as a string. andi'm guessing the sno column is an int.

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups