Solved

SQL Statement

Posted on 2014-09-09
6
170 Views
Last Modified: 2014-09-10
Hi,

I have the SQL statement below that’s works but puts ‘ ’ around the results of the column micros.mi_def.name_1 , how can I remove the ‘ ’ ?


Results:
1001011,'Fishcakes',21,3
1005009,'Angus Burger',11,1
1005019,'Bacon Burger',24,2
1006004,'Four Cheese',18,2

SQL:
SELECT item = micros.mi_def.obj_num, name = micros.mi_def.name_1, Sales = SUM(CONVERT(INT, (price_1_sls_ttl+price_2_sls_ttl+price_3_sls_ttl+price_4_sls_ttl))), Quantity = sum(price_1_sls_cnt+price_2_sls_cnt+price_3_sls_cnt+price_4_sls_cnt)
FROM micros.rest_status, micros.rvc_def, micros.dly_rvc_mi_ttl
right outer join micros.mi_def
where rvc_def.rvc_seq = dly_rvc_mi_ttl.rvc_seq
and mi_def.maj_grp_seq in (1,2,3)
and dly_rvc_mi_ttl.business_date = rest_status.business_date -1
GROUP BY micros.mi_def.maj_grp_seq, micros.mi_def.obj_num, micros.mi_def.name_1
ORDER BY item;
output to 'c:\export\test.001'
0
Comment
Question by:hellblazeruk
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 40312406
What database are you running against?

I suspect it is a setting in your database configuration to export text fields with quotes around them.

mlmcc
0
 
LVL 18

Expert Comment

by:vasto
ID: 40312652
This is normal. The type of micros.mi_def.name_1 is varchar, string, text ( whatever is the type for string in your database) and the export will add ' to distinct the text from the other data. Actually this formatting is done by the command "output" and this is not a SQLServer command ( at leas not SQL92). Search for options for this command , may be there is a parameter , which will allow you to export the data without formatting
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 40313239
What database are you using please?

Your query has syntax issues, and while you state "it works" it may not be reliable.
1. There are 4 tables in the FROM clause, but only 2 join conditions in the WHERE clause (so there is a missing join condition)
2. you mix non-ANSI and ANSI join syntax, that is never good. Use only ANSI syntax.

FROM micros.rest_status
   , micros.rvc_def
   , micros.dly_rvc_mi_ttl
     RIGHT OUTER JOIN micros.mi_def --<< missing ???

WHERE rvc_def.rvc_seq = dly_rvc_mi_ttl.rvc_seq
      AND dly_rvc_mi_ttl.business_date = rest_status.business_date - 1

      AND mi_def.maj_grp_seq IN (1, 2, 3)

Open in new window

0
 

Author Comment

by:hellblazeruk
ID: 40314646
Hi,

the database is SQL anywhere 11.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40314788
Try changing the output line to

OUTPUT TO 'c:\export\test.001' FORMAT ASCII DELIMITED BY ',' QUOTE '';

mlmcc
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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