Solved

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

Posted on 2008-10-28
6
787 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Backup skipping a few tables 7 26
@Html.EditorFor displays mm/dd/yyyy rather than date 2 19
SQl query 19 13
Mssql SQL query 14 28
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

19 Experts available now in Live!

Get 1:1 Help Now