How to enter new line using sql command INSERT

僤鯓⒐⒋嵵緔 提交于 2020-01-15 06:55:46

问题


Q:

I wanna to know the syntax of SQL query of inserting new line in my table.

I mean ,I wanna to enter the following in my table abc:

  aaaaaaaaaa

  bbbbbbbbbb

  cccccccccccc

Maintaining the new line.through INSERT command .

Thanks in advance


回答1:


When I answered this question, you'd got it tagged with SQL Server 2008. You've since edited it to be about Informix. The following works for SQL Server 2008.

INSERT INTO MyTable(MyField) VALUES('AAAAA' + CHAR(13) + CHAR(10) + 'BBBBB')

Informix looks more complicated. You have to set an option according to this documentation I found with a google for "informix sql newline"

EXECUTE PROCEDURE IFX_ALLOW_NEWLINE('T')



回答2:


Never used informix but for SQL Server 2008 this is just.

INSERT INTO abc
            (col1)
VALUES (
'aaaaaaaaaa

bbbbbbbbbb

cccccccccccc');



回答3:


INSERT INTO MyTable(MyColumn) VALUES ('aaaaaaaaaa

bbbbbbbbbb

cccccccccccc');



回答4:


why not store the row without the newline, then on the client side of your app, provide for it?




回答5:


It depends whether you're using Windows or *nix conventions, but it will be some combination of \r and \n

Have a look at the New line in Sql Query question.



来源:https://stackoverflow.com/questions/7377382/how-to-enter-new-line-using-sql-command-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!