Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

sql stored procedure using IN Statement

$
0
0

hi below is my stored procedure, but im not able to get the results

alter PROCEDURE homepageitems

        @categoryid int,
                @websiteid  int
        ,@websiteitems VARCHAR(15)


AS
BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

   SELECT Product.id, Product.name, Product.Price, categoryid FROM product where  Product.Published=1 and Product.Deleted=0
     and Categoryid=@categoryid and websiteid=@websiteid and product.id in (' + @websiteitems + ')
END


GO

--------------

DECLARE    @return_value int

EXEC    @return_value = [dbo].[homepageitems]
        @categoryid = 67,
        @websiteid = 2,
        @websiteitems = N'75530,75667,75518,75953'

SELECT    'Return Value' = @return_value

GO

Msg 245, Level 16, State 1, Procedure homepageitems, Line 20
Conversion failed when converting the varchar value ' + @websiteitems + ' to data type int.

and Im supplying the correct values of websiteitems (75530,75667,75518,75953) and Product.id is integer field, how do i supply when im using IN Statement


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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