Solved

Sql Server error , Syntax error converting the varchar value ';' to a column of data type int

Posted on 2008-10-28
6
788 Views
Last Modified: 2012-08-13
am getting error , in sql..
Sql Server error , Syntax error converting the varchar value ';' to a column of data type int
my table structure
table1:foodtable field                                            
fid int(identity(1,1),primary)
fname varchar                                                        
table 2:Resttable          
1.Rid primary key                                                  
2. resname varchar                                                      
table3 : MAintable                                                    
1.pid int(identity(1,1),primary)                                    
2.fid int foriegn key(foodtable)
3..rid  int  foreign key(resttable)
4.price float    

SELECT rt.resname, rt.rid + ';' + mt.price + ';' + mt.fid

FROM Resttable rt inner join Maintable mt

on rt.rid = mt.rid

inner join foodtable ft

on ft.fid = mt.fid

Open in new window

0
Comment
Question by:Rajar Ahmed
6 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 22821167
cast your fields

SELECT rt.resname, cast(rt.rid as varchar) + ';' + cast(mt.price as varchar) + ';' + cast(mt.fid as varchar)
 
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 22821172
You need to convert to a string-based data type:

SELECT rt.resname, CONVERT(varchar(20), rt.rid) + ';' + CONVERT(varchar(20), mt.price) + ';' + CONVERT(varchar(20), mt.fid)
0
 
LVL 3

Expert Comment

by:Blackninja2007
ID: 22821174
as rid, price and fid are numeric you cannct add them to string ';' you'll need to convert/cast your numbers to strings :-

 SELECT rt.resname, cast(rt.rid as varchar(10)) + ';' + cast(mt.price as varchar(10) + ';' + cast(mt.fid as varchar(10))

 SELECT rt.resname, convert(varchar(10), rt.rid) + ';' + convert(varchar(10), mt.price) + ';' + convert(varchar(10), mt.fid )
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 22821175
too slow :)
0
 
LVL 18

Author Comment

by:Rajar Ahmed
ID: 22821269
sorrry , Der was power failure
Thanks a lot ......it works....
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 22821466
meeran03, you seem to be new here. To close a question, you need to accept (at least) one of the comment.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Auto refresh part of an MVC5 View 7 54
Resolve Dependency Issues 4 42
Error on Add method 1 37
Get Duration of last Status Update 4 29
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now