?
Solved

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

Posted on 2008-10-28
6
Medium Priority
?
797 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 1500 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 93

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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 93

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

770 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