473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

concatenation with space

Hi,

I am unable to concat 2 fields with a space between them in sql query.
I want to write my query in following fashion only as there are many conditions which I concat. Thus I am using variable @sql_st and not the direct sql statement.

Following query works perfect
DECLARE @SQL_ST VARCHAR(8000)
set @SQL_ST = 'SELECT EM.EMPLOYEE_ID,
(EM.FIRST_NAME + EM.LAST_NAME) as emp_name from employee_master em'
execute (@SQL_ST)

but when modified to get space between first & last name of employee I get an error
DECLARE @SQL_ST VARCHAR(8000)
set @SQL_ST = 'SELECT EM.EMPLOYEE_ID,
(EM.FIRST_NAME + ' ' + EM.LAST_NAME) as emp_name from employee_master em'
execute (@SQL_ST)

Pls reply ASAP.

Thanks
Shubhangi
Sep 26 '06 #1
3 7350
Senthil
10
Hi,

USE the below...

DECLARE @SQL_ST VARCHAR(8000)
set @SQL_ST = 'SELECT EM.EMPLOYEE_ID,
(EM.FIRST_NAME + ' + ' ' + 'EM.LAST_NAME) as emp_name from employee_master em'
execute (@SQL_ST)

Cheers,
Sharmila
Sep 26 '06 #2
Hi,

Space doesn't appears between first & last name using the below query.
please reply.

Hi,

USE the below...

DECLARE @SQL_ST VARCHAR(8000)
set @SQL_ST = 'SELECT EM.EMPLOYEE_ID,
(EM.FIRST_NAME + ' + ' ' + 'EM.LAST_NAME) as emp_name from employee_master em'
execute (@SQL_ST)

Cheers,
Sharmila
Sep 26 '06 #3
Senthil
10
Hi,


Sorry Please use like this..

DECLARE @SQL_ST VARCHAR(8000)
set @SQL_ST = 'SELECT EM.EMPLOYEE_ID,
(EM.FIRST_NAME + '' '' + ' + ' ' + 'EM.LAST_NAME) as emp_name from employee_master em'
print @SQL_ST


Regards,
Sharmila
Sep 28 '06 #4

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

Similar topics

6
by: Jonathan | last post by:
Why did the designers of PHP decide to use period (".") as the string concatenation operator rater than the obviously more logical plus ("+")? //JJ
5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
14
by: Marcin Ciura | last post by:
Here is a pre-PEP about print that I wrote recently. Please let me know what is the community's opinion on it. Cheers, Marcin PEP: XXX Title: Print Without Intervening Space Version:...
8
by: mrstephengross | last post by:
I'm using gcc 3.3.1 to compile the following code (below). I've written a macro to simplify writing operators. The macro uses the '##' operator to paste together 'operator' and the name of the...
3
by: Locia | last post by:
I have a Template base class and another subclasses of Template. I have a tree structure of template object. class Template { ArrayList child; public virtual String Eval(Environment env) {
2
by: barry | last post by:
Below is a piece of code in which I am trying to concatenate two items into an arraylist. I have separated them with a " " but when I increase this to say " " only one space is allowed. I...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
34
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
2
by: mochatrpl | last post by:
Is there a way to create a Concatenation Query for 2 columns and at the same time, remove the spacing between them? The fields that I am combining are 2 text fields but for some reason there is 15...
1
by: =?Utf-8?B?UGFzcXVhbGU=?= | last post by:
I want to send an email with smtpclient. I have created a MailMessage with body obtained as concatenation between a fixed string, that finishes with a space, and a string variable. The code is as...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.