Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 very urgent

Author  Topic 

sureshkumar
Starting Member

11 Posts

Posted - 2004-07-20 : 11:16:27
Hi

The following table will product size in product_master will have different data like 4s,10,40gm, 40 ml like different
if case ='s'
then
(rate / cast(left(product_size,len(product_size)-1) as int))
else
rate
end

complete query is given below.
select sum((closing_stock * (case when lower(right(product_size,1))='s' then (rate / cast(left(product_size,len(product_size)-1) as int)) else rate end))) as stock_value
from stock s, product_master p
where s.product_code=p.product_code

while executing error "Syntax error converting the nvarchar value '450gm' to a column of data type int." getting following error message

Reply me urgent
thanks and regards
suresh kumar.a

Kristen
Test

22859 Posts

Posted - 2004-07-20 : 11:28:39
Looks like you have got "450gms" somewhere in your data

SELECT product_size
FROM product_master
WHERE product_size LIKE '%s'
AND IsNumeric(LEFT(product_size, LEN(product_size)-1)) = 0

"Reply me urgent"

Why, are you willing to pay my expediting fee?

Kristen
Go to Top of Page

sureshkumar
Starting Member

11 Posts

Posted - 2004-07-21 : 00:58:10
450 ml, 4500ml, 450gm ,450ml sample type which iam having even Null values are there. Another Field Type is Nvarchar(10).
Now its showing error even for 30gm product size.


Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-07-21 : 01:27:39
None of those will cause this query to fail. Did you run my query?

Kristen
Go to Top of Page
   

- Advertisement -