This allows you to specify a separator to be used in between each string. If you’re concatenating more than two strings, and you need a space (or other separator), consider using the CONCAT_WS() function. So if we apply this to a database, then the query might look something like this: SELECT CONCAT(FirstName, ' ', LastName) AS 'Full Name' Which may or may not be the result you’re looking for. If I didn’t add the space it would’ve looked like this: SELECT CONCAT('Peter', 'Griffin') AS 'Full Name' I concatenated the first name, the last name, plus a space. Note that I actually concatenated 3 strings here. Here’s an example: SELECT CONCAT('Peter', ' ', 'Griffin') AS 'Full Name' In SQL Server (and in any computer programming environment), string concatenation is the operation of joining character strings end-to-end. You can also use SQL Server’s string concatenation operator ( +) to do the same thing. In SQL Server, you can concatenate two or more strings by using the T-SQL CONCAT() function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |