'Updating data with new line in Microsoft SQL Server
Working on a school projcet:
I have a project that create reports using data from a table in a database. The table contain info about a customer, such as address/name etc. I am trying to update the name of the customer for the report by updating the table in the database. However, new name is two lines instead of one.
Example, current name is "University Fun Club" and the current report uses this as the name of the customer for the report. Example:
Report to:
University Fun Club
I would like it to show:
Report to:
3rd Division
University Fun Club
Is it possible to update the data in the table to:
"3rd Division
University Fun Club"
?
Solution 1:[1]
You can use a literal newline in your insert.
create table test (col1 varchar(100)); insert into test values ('3rd Division University Fun Club');
select col1 "Report to:" from test
| Report to: | | :---------------------------------- | | 3rd Division | University Fun Club |
db<>fiddle here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
