Solved

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

Posted on 2008-10-28
6
795 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 70

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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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 70

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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