Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Multi-line text values in INSERT ?

Author  Topic 

MrBean
Starting Member

14 Posts

Posted - 2003-09-10 : 06:29:07
Is it possible to insert a multi-line values into a text field thru a INSERT or UPDATE ?

Normally I would use a bound value thru a ADO recordset but in this case I'm restricted to using SQL commands :(

MrBean
Starting Member

14 Posts

Posted - 2003-09-10 : 06:54:51
Silly me... I found a solution :)

insert into test values ('Line 1'+char(13)+char(10)+'Line 2'+char(13)+char(10)+'Line 3')
Go to Top of Page

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2003-09-10 : 07:49:10
quote:
Originally posted by MrBean
insert into test values ('Line 1'+char(13)+char(10)+'Line 2'+char(13)+char(10)+'Line 3')




insert into test values ('Line 1'+SPACE(23)+'Line 2'+SPACE(23)+'Line 3')


Sorry misread the question.



------------------------------------------------------------------------------
I enjoy using SQL Server but I am not part of the Microsoft fanboy club! NEVER!!
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-09-10 : 07:50:35
Why the SPACE(23) ?? I believe the CR/LF between each line is probably what he wants.

- Jeff
Go to Top of Page

MrBean
Starting Member

14 Posts

Posted - 2003-09-10 : 07:58:48
Thanks for the attention, guys :)

This may be a bit offtopic on a SQL Server forum, but is the CHAR function standard ANSI-SQL ?

Does it also work on Oracle, MySQL and AS/400 ?

Go to Top of Page

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2003-09-17 : 13:07:09
Char is not an ANSI function. It works in Mysql though. Not in Oracle. AS/400 I don't know.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-09-17 : 13:11:28
i believe it works for ODBC as well, so if you use that to connect it should be available regardless of what you connect to if the ODBC driver is fully implemented.

I think it's called Chr() and not char(), though.

- Jeff
Go to Top of Page
   

- Advertisement -