How To Concatenate Two Character Strings Together?
Submitted by: AdministratorConcatenating 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 = 'GlobalGuideLine.com';
SELECT 'Welcome to '+@site;
SELECT 'Current date and time is '
+CONVERT(VARCHAR(20), GETDATE());
GO
Welcome to GlobalGuideLine.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
Submitted by: Administrator
DECLARE @site VARCHAR(40);
SET @site = 'GlobalGuideLine.com';
SELECT 'Welcome to '+@site;
SELECT 'Current date and time is '
+CONVERT(VARCHAR(20), GETDATE());
GO
Welcome to GlobalGuideLine.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
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Start SQL Server Browser Service? |
☺ | How to download Microsoft SQL Server 2005 Express Edition? |
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | How To Configure ODBC DSN with Different Port Numbers? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |