Solved

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

Posted on 2008-10-28
6
791 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 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Master DB with Masterkey 1 34
union query column need default text 2 15
Stored Proc - Rewrite 42 59
Are triggers slow? 7 12
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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