November 7, 2011 at 11:15 am
Hi,
I have a query with update statement
UPDATE #Rpt
SET Productfamily = PD.pt_sp_type_c
FROM #Rpt s
INNER JOIN #ProductDetails PD on PD.pt_sb_type_c = s.CONVERT(VARCHAR(10),productId) --03112011
here pt_sp_type_c and pt_sb_type_c both are varchar(10) and productId is integer
so when i am trying to execute teh query its showing that cannot convert varchar to int..i am changing productId to varchar for that i am using
cast and convert for me its showing incorrect syntax near the keyword convert
whern i use cast s.CAST(productId AS VARCHAR(10)) --here its showing incorrect syntax near keyword AS can anyone come with appropraite answer..
November 7, 2011 at 11:20 am
Try CAST(s.productId AS VARCHAR(10)). The way you had it made it think that CAST is a column in s. Your convert would work the same way.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 7, 2011 at 5:48 pm
shalini72011 (11/7/2011)
Hi,I have a query with update statement
UPDATE #Rpt
SET Productfamily = PD.pt_sp_type_c
FROM #Rpt s
INNER JOIN #ProductDetails PD on PD.pt_sb_type_c = s.CONVERT(VARCHAR(10),productId) --03112011
here pt_sp_type_c and pt_sb_type_c both are varchar(10) and productId is integer
so when i am trying to execute teh query its showing that cannot convert varchar to int..i am changing productId to varchar for that i am using
cast and convert for me its showing incorrect syntax near the keyword convert
whern i use cast s.CAST(productId AS VARCHAR(10)) --here its showing incorrect syntax near keyword AS can anyone come with appropraite answer..
And what is the data-type of ProductFamily?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply