473,729 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to concat multiple fields in query?

This returns only txt1. Any thoughts?

Columns are (varchar (250),Null).


Expand|Select|Wrap|Line Numbers
  1. select distinct 
  2. employee_name, 
  3. tran_date, 
  4. billed_hrs, 
  5. (txt1 + txt2 + txt3 + txt4 +txt5 + txt6) as Narrative  
  6.  
  7. from tat_time 
  8. left outer join hbm_matter on
  9. tat_time.matter_uno = hbm_matter.matter_uno
  10. left outer join hbm_persnl on
  11. tat_time.tk_empl_uno = hbm_persnl.empl_uno
  12. left outer join tat_text on
  13. tat_time.time_uno = tat_text.source_uno
  14.  
  15. where clnt_matt_code = '013187.0000041'
  16. and wip_status = 'B'
  17. and billed_hrs != 0
  18. order by tran_date
Nov 6 '10 #1
6 3387
gpl
152 New Member
What does your data look like ?
Nov 7 '10 #2
try this
......

(isnull(txt1,'' ) +isnull(txt2,'' ) + isnull(txt3,'') + isnull(txt4,'') +isnull(txt5,'' ) + isnull(txt6,'') ) as Narrative
Nov 8 '10 #3
The date is narrative in a time and billing system. Once 250 characters are used in txt1, txt2 is used, and so on. Narrative like "Conference with so and so regarding such and such."
Nov 9 '10 #4
ck9663
2,878 Recognized Expert Specialist
First, you can actually increase your varchar length more than 250...

In your case, try to isolate the problem first...are all those txt<x> columns coming from a single table? Maybe one or some of those are NULL. Try doing with Sandeep recommended. If you want to isolate your problem, replace the "+" sign with comma, remove the "as Narrative" and the parenthesis, that way you'll know what the value of each of those fields are. If the other txt<x> fields are empty, then it will not be concatenated. You have to check if these columns are properly populated...

Good Luck!!!

~~ CK
Nov 9 '10 #5
Thank you both. But Isnull does not help. With or without isnull, it picks up the first 6 character in txt2 then drops the remainder of txt2 and nothing beyond that. Yes, I can get the full text in each column using commas and concatenate them in Excel. Yes, the columns are all in one table. Can't change the properties of the tables or columns. In some cases, txt2, txt3, txt4, etc may or may not be populated.
Nov 9 '10 #6
It seems the problem is my version of SQL Analyser 8.0 is the culprit. Tried a more elaborate script written by one of our prgrammers:

Expand|Select|Wrap|Line Numbers
  1. 'DESC_COMMENTS'=ISNULL(CONVERT(TEXT,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
  2.  
  3.       (REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(TXT1)),
  4.  
  5.       CHAR(10),Space(1)),CHAR(13),Space(1)),CHAR(9),Space(1)),CHAR(10)+CHAR(13),Space(1)),CHAR(13)+CHAR(10),SPACE(1)),
  6.  
  7.       Space(5),Space(1)),Space(4),Space(1)),Space(3),Space(1)),Space(2),Space(1)) + 
  8.  
  9.       REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(TXT2)),
  10.  
  11.       CHAR(10),Space(1)),CHAR(13),Space(1)),CHAR(9),Space(1)),CHAR(10)+CHAR(13),Space(1)),CHAR(13)+CHAR(10),SPACE(1)),
  12.  
  13.       Space(5),Space(1)),Space(4),Space(1)),Space(3),Space(1)),Space(2),Space(1)) + 
  14.  
  15.       REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(TXT3)),
  16.  
  17.       CHAR(10),Space(1)),CHAR(13),Space(1)),CHAR(9),Space(1)),CHAR(10)+CHAR(13),Space(1)),CHAR(13)+CHAR(10),SPACE(1)),
  18.  
  19.       Space(5),Space(1)),Space(4),Space(1)),Space(3),Space(1)),Space(2),Space(1)) + 
  20.  
  21.       REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(TXT4)),
  22.  
  23.       CHAR(10),Space(1)),CHAR(13),Space(1)),CHAR(9),Space(1)),CHAR(10)+CHAR(13),Space(1)),CHAR(13)+CHAR(10),SPACE(1)),
  24.  
  25.       Space(5),Space(1)),Space(4),Space(1)),Space(3),Space(1)),Space(2),Space(1)) + 
  26.  
  27.       REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(TXT5)),
  28.  
  29.       CHAR(10),Space(1)),CHAR(13),Space(1)),CHAR(9),Space(1)),CHAR(10)+CHAR(13),Space(1)),CHAR(13)+CHAR(10),SPACE(1)),
  30.  
  31.       Space(5),Space(1)),Space(4),Space(1)),Space(3),Space(1)),Space(2),Space(1)) + 
  32.  
  33.       REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(TXT6)),
  34.  
  35.       CHAR(10),Space(1)),CHAR(13),Space(1)),CHAR(9),Space(1)),CHAR(10)+CHAR(13),Space(1)),CHAR(13)+CHAR(10),SPACE(1)),
  36.  
  37.       Space(5),Space(1)),Space(4),Space(1)),Space(3),Space(1)),Space(2),Space(1))),
  38.  
  39.       CHAR(10),Space(1)),CHAR(13),Space(1)),CHAR(9),Space(1)),CHAR(10)+CHAR(13),Space(1)),CHAR(13)+CHAR(10),SPACE(1)),
  40.  
  41.       Space(5),Space(1)),Space(4),Space(1)),Space(3),Space(1)),Space(2),Space(1))),'No narrative.')
  42.  
which works on 2005 but still comes up short on 8.0. I'm going to upgrade. Thanks for all your help.
Nov 9 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8796
by: Ben Willcox | last post by:
Hi I am having difficulty writing an SQL query to do what I want: I have 1 table with 2 columns, 'id' and 'name': tbl_names: id name -- ---- 1 Bob 2 Jeff 3 Fred
2
2142
by: PPT33R | last post by:
The MS Access website is very unhelpful on this topic, and I cannot find anything in my Googling to find a hint. I am working with very large, existing data sets that consist of multiple fields. Two of the fields are "Origin" and "Destination". These fields contain the FAA Airport Codes, so the data is similar. I also have another table with all FAA Airport Codes, corresponding FAA Airport Categories, and Airport Names. I need to...
3
3475
by: tesc | last post by:
I am so aggravated and need any help I can get. I am using Access 2000 and am trying to sort multiple fields in a select query. My query is set up as follows: FIELD 1 FIELD 2 FIELD 3 FIELD4 FIELD 5 FIELD 6 MSA03 MSA 02 % change ICU 03 ICU 02 % change calc. calc. This format continues and in some queries I have up to 13 percentages to sort. I need to sort each percentage to show over 20%...
7
7249
by: spamsickle | last post by:
My database stores City and State in two separate columns, but I want to display them on my form as a single field. Since I'm a complete VB novice, I'm not sure how to do this. I bind the data, and I can bring each field into my forn as a separate textbox. I created a third textbox, and added code in the Form_Paint routine to concatenate the fields: CityStateTextBox.Text = CityTextBox.Text + ", " + StateTextBox.Text This displayed...
3
30287
by: mkjets | last post by:
I have worked for hours on trying to find a solution and have not figured it out. I am working in Access 2003. I need to create a query that takes values from 1 table and displays them in multiple fields. I don't have the option of changing the structure of the existing tables because I am importing them from a separate data source on a regular basis. I also need to use a query instead of a form because I then need to be able to export...
11
2365
by: nsymiakakis | last post by:
Hello everyone, I know Access fairly well, but I am very, very weak on SQL. I have a very large table that I need to pull a grand Total from multiple fields. I have created a query to SUM all the fields individually, but I do not know how to add all the field totals to get one Grand Total. Here are 4 fields from my query as an example. SELECT Sum(.) AS , Sum(.) AS , Sum(.) AS , Sum(.) AS FROM ; Please be specific in the...
2
2674
by: Nathan Sokalski | last post by:
I have a Repeater that uses a DataSource that has multiple fields. When the values of these fields is displayed in the Repeater, there are fields that are used in combination with other fields as well as by themselves. For example, there may be a firstname field that is used in combination with a lastname field as well as by itself. Using it by itself is simple, I have done that many times. However, is there a way to use multiple fields in...
482
27901
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. what i am trying to display previously entered multiple fields. I am able to get my serial fields to display correctly, but i can not display my parts fields correctly. Currently this is what it does serial information 1 parts 1
2
2310
by: abirch | last post by:
Hey. So the problem that I'm running into involves auto-numbering invoice numbers. My boss has 3 tables, 2 of which are only to temporarily store information, but when she goes to create a new invoice number, it doesn't take into consideration all three tables, and therefore she is getting repeat invoice numbers - a real nightmare. To fix this, I want to code a DMax + 1 function instead of the autonumber, but I am running into the issue of...
0
8921
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8763
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9202
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9148
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8151
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.