如何在 SQL Server 2005 中连接两个字符串 [英] How to concatenate two strings in SQL Server 2005
本文介绍了如何在 SQL Server 2005 中连接两个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想连接dummy's"和dock"这两个词.
I want to concatenate the words "dummy's" and "dock".
如何在 SQL Server 2005 中连接它们?是否支持双引号?
How can I concatenate them in SQL Server 2005? Does it support double quotes?
推荐答案
试试这个:
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;
输出:
rupesh'smalviya
只需在字符串中添加一个空格作为分隔符即可.
Just add a space in your string as a separator.
这篇关于如何在 SQL Server 2005 中连接两个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文