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)
 Inserting strings containing apostrophes

Author  Topic 

RobVG
Starting Member

42 Posts

Posted - 2003-07-11 : 13:34:00
How do you insert a string containing an " 's " w/o getting an unclosed quote error?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-07-11 : 13:45:25
CREATE TABLE Table1
(
Column1 VARCHAR(100) NOT NULL
)

INSERT INTO Table1 VALUES('You''re cool.')

SELECT * FROM Table1

DROP TABLE Table1


-------
[EDIT]Those are single quotes above.[/EDIT]

Tara

Edited by - tduggan on 07/11/2003 13:47:08
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-07-11 : 13:54:38
And if you start to build some complicated strings, I like to keep the ticks separated by themselves, just so you don't drive yourself crazy...so I know that 4 ticks = 1 in the string. Like:

SELECT ''''+ 'A' + ''''


Which is the same as:

SELECT '''A'''


Brett

8-)

Edited by - x002548 on 07/11/2003 13:55:41
Go to Top of Page

RobVG
Starting Member

42 Posts

Posted - 2003-07-11 : 14:35:39
Thanks People!

(It looks funny-but it works )
Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2003-07-11 : 14:45:45
Rob-
Read up on QUOTENAME() in BOL.

Jonathan
{0}
Go to Top of Page

RobVG
Starting Member

42 Posts

Posted - 2003-07-12 : 00:53:19
-Jonathan

Ok, I give up... what does BOL mean?





I might as well reiterate... brand-spanking-Newbie.

Edited by - RobVG on 07/12/2003 01:14:04
Go to Top of Page

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2003-07-12 : 16:19:21
Books On Line

...and if you search for QUOTEIDENTIFIER you will find it useful when inserting complex strings.

---------------
Shadow to Light

Edited by - Amethystium on 07/12/2003 16:21:41
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-07-14 : 10:07:22
quote:

Books On Line

...and if you search for QUOTEIDENTIFIER you will find it useful when inserting complex strings.

---------------
Shadow to Light

Edited by - Amethystium on 07/12/2003 16:21:41



Huh?

How?



Brett

8-)
Go to Top of Page
   

- Advertisement -