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
 SQL Server Development (2000)
 text input

Author  Topic 

heze
Posting Yak Master

192 Posts

Posted - 2006-04-07 : 12:22:33
Hi, I want to insert very long text with the characteristics shown below, however doing it the shown way I would have to type t=''something'' and its just not possible when text is long and have many cases like this, is there a way to just take whatever text, with whatever characteristics and insert it into a text field?


insert into mytab (queryitself)
values('very long text including t='something'')

--generates error

thank you

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-07 : 12:25:48
I assume you are copying the text from somewhere.
copy it to a new window, replace all the ' by '' then copy it in to the string.
also I would

declare @s varchar(8000)
select @s = 'very long text including t=''something'''

insert mytab (queryitself)
select @s

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

heze
Posting Yak Master

192 Posts

Posted - 2006-04-07 : 12:43:39
thanks nr, the problem is the following. We produce a lot of queries. We want to keep track of them and describe them all in the database. Therefore, everytime we finish a script which can be from 5 lines to 1000 lines we want to insert it into a text field. Doing what you suggest would mean doing this for every insert, thus we would not be preserving the original characteristics of the text. The idea is to retreive the script and execute it by just placing it in the query analizer, without having to do more stuff.

thank you
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-08 : 17:44:36
You are preserving the original characteristics of the text - it's just the way you are doing the insert that causes the intermediate string to need to be changed.

You could put the query into a file then bcp it into the table if you have something against the above.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

heze
Posting Yak Master

192 Posts

Posted - 2006-04-09 : 21:27:04
thanks nr, your suggestion is useful for other purposes as well. For example when one wants to use the datalength() fucntion we can wrap large chunks of text by ctrl-h and then replace all the ' for '' and fuinally adding one ' in the beginning and one in the end.
Go to Top of Page
   

- Advertisement -