tags:

views:

47

answers:

3

see i want to concatenate this

rupesh's and malviya

so how can i concenate it in sql server 2005 and also i want to know does it support double quotes?

+1  A: 

Try this:

DECLARE @COMBINED_STRINGS AS VARCHAR(50); -- Allocate just enough length for the two strings.

SET @COMBINED_STRINGS = 'rupesh''s' + 'malviya';
SELECT @COMBINED_STRINGS; -- Print your combined strings.

Or you can put your strings into variables. Such that:

DECLARE @COMBINED_STRINGS AS VARCHAR(50),
        @STRING1 AS VARCHAR(20),
        @STRING2 AS VARCHAR(20);

SET @STRING1 = 'rupesh''s';
SET @STRING2 = 'malviya';
SET @COMBINED_STRINGS = @STRING1 + @STRING2;

SELECT @COMBINED_STRINGS; 

Output:

rupesh'smalviya

Just add a space in your string as a separator.

yonan2236
could u describe me how does it work 'rupesh''s'
NoviceToDotNet
+1  A: 

Try something like

SELECT 'rupesh''s' + 'malviya'

+ (String Concatenation)

astander
+1  A: 

so if you have a table with a row like:

firstname lastname
Bill      smith

you can do something like

select firstname + ' ' + lastname from thetable

and you will get "Bill Smith"

John Boker