Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - Concatenating Two Character Strings

By: FYIcenter.com

(Continued from previous topic...)

How To Concatenate Two Character Strings Together?

Concatenating two character strings together is most commonly used string operation. SQL Server 2005 allows to concatenate two character strings into a single string with the (+) operator. The following tutorial exercise shows you some string concatenation examples:

DECLARE @site VARCHAR(40);
SET @site = 'FYIcenter.com';
SELECT 'Welcome to '+@site;
SELECT 'Current date and time is '
   +CONVERT(VARCHAR(20), GETDATE());
GO
Welcome to FYIcenter.com
Current date and time is May 19 2007  5:18PM

DECLARE @start INT, @end INT, @total INT;
SET @start = 21; 
SET @end = 30;
SET @total = 728;
SELECT 'Search result '
   + CONVERT(VARCHAR(20),@start)
   + ' - '
   + CONVERT(VARCHAR(20),@end)
   + ' of '
   + CONVERT(VARCHAR(20),@total);
GO
Search result 21 - 30 of 728

(Continued on next topic...)

  1. How To Concatenate Two Character Strings Together?
  2. What Happens When Unicode Strings Concatenate with Non-Unicode Strings?
  3. How To Convert a Unicode Strings to Non-Unicode Strings?
  4. What Are the Character String Functions Supported by SQL Server 2005?
  5. How To Insert New Line Characters into Strings?
  6. How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions?
  7. How To Concatenate Two Binary Strings Together?
  8. Can Binary Strings Be Used in Arithmetical Operations?
  9. How To Convert Binary Strings into Integers?
  10. Can Binary Strings Be Converted into NUMERIC or FLOAT Data Types?
  11. Can Binary Strings Be Converted into Character Strings?
  12. Can Binary Strings Be Converted into Unicode Character Strings?
  13. How To Convert Binary Strings into Hexadecimal Character Strings
  14. What Are Bitwise Operations?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...