Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

conversion failed when converting the nvarchar value '%' to data type int

Posted on 2009-05-19
5
Medium Priority
?
1,230 Views
Last Modified: 2012-05-07
I've created a SP with select statement for use with crystal report. There is no cast/convert statement in the SP. This error occurred after i added in new columns into the view. Please help. Thanks

Here's the SP syntax :

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
 
 
 
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[CST_Std Material Cost]
 
	@BP varchar(10),
	@ProcessVal char(1)
 
	
AS
 
If @ProcessVal = '1' /*With landed cost*/
BEGIN
 
	select * from  reporting.dbo.[Item Master With Cost] left join  reporting.dbo.[Supplier Price Catalogue]
	on ibitm = cbitm and ibmcu = cbmcu
	where ltrim(ibmcu) = rtrim(@BP) and a6prp5 <> ''
 
 
END
 
If @ProcessVal = '2' /*Without landed cost*/
BEGIN
 
	select * from  reporting.dbo.[Item Master With Cost] left join  reporting.dbo.[Supplier Price Catalogue]
	on ibitm = cbitm and ibmcu = cbmcu
	where ltrim(ibmcu) = rtrim(@BP)  and a6prp5= ''
 
END
 
If @ProcessVal = '3' /*All*/
BEGIN
 
	 	select * from  reporting.dbo.[Item Master With Cost] left join  reporting.dbo.[Supplier Price Catalogue]
	on ibitm = cbitm and ibmcu = cbmcu
	where ltrim(ibmcu) = rtrim(@BP)
 
END

Open in new window

0
Comment
Question by:sacred21
  • 3
5 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 80 total points
ID: 24428493
what are the datatypes of  ibitm , cbitm and ibmcu , cbmcu
0
 
LVL 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 80 total points
ID: 24428767
So what changed? New fields in dbo.report? What new fields? Did you change the stored procedure? You SELECT * FROM dbo.reports, so you select new fields. If The crystal report has no use for the new fields you're perhaps getting the error therefore.

What error do you get? Do you get it from SQL Server or from crystal report?

Bye, Olaf.
0
 

Author Comment

by:sacred21
ID: 24428770
ibitm & cbitm are float

ibmcu & cbmcu are nchar
0
 

Author Comment

by:sacred21
ID: 24428781
To Olaf,

The error was from MS-SQL. The complete error message is
"Database connector error 22018 : [Microsoft][SQL Native Client][SQL Server] conversion failed when converting the nvarchar value '%' to data type int"

The new fields are being added into the views ([Item Master With Cost] & [Supplier Price Catalogue] are views)
0
 

Accepted Solution

by:
sacred21 earned 0 total points
ID: 24428995
Anyway, i managed to solve the issue by removing the parameters and put them back into the SP and verfiy the crystal report. It works fine now.

Thanks all for your effort & attention.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question