Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2014
    Posts
    3

    Unanswered: How to convert varchar type to integer here?

    Hello Everyone,

    Please checkout this sql command and let me know the mistake i did.


    declare @found int;
    set @found = 'select sid from StickyContent where StickyId='+0+' and UserId='+171
    exec (@found)
    delete from StickyContent where sid = @found

    i need to pass this statement from my UI i.e in a single query
    i am getting this error.
    "Conversion failed when converting the varchar value 'select sid from StickyContent where StickyId=' to data type int.
    "


    any suggestions would be thankful.

    Thanks in Advance
    Satish Chandragiri

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    I think you want something more along the lines of
    Code:
    declare @found int;
    select @found = sid 
    from StickyContent 
    where StickyId = 0 
      and UserId = 171
    
    delete from StickyContent where sid = @found
    Right now, you are trying to convert the text of the query to an integer, rather than the result of the query.

  3. #3
    Join Date
    Sep 2014
    Posts
    3

    How to convert varchar type to integer here? Reply to Thread

    Hi MCrowley,

    Thanks for u'r reply. It's working 5n for me. Thanks a lot


    Regards
    Satish Chandragiri

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •