Mehdi
Mehdi

Reputation: 339

Setting a character variable which consists of this (') character

I want to set a variable to expressions like this 'word' in SQL which consists of this (') character.

How can I do that?

Upvotes: 0

Views: 47

Answers (2)

Jahirul Islam Bhuiyan
Jahirul Islam Bhuiyan

Reputation: 799

For SQL Server to show ' use '' into select

SELECT 'aa''a'

Upvotes: 3

HaveNoDisplayName
HaveNoDisplayName

Reputation: 8497

You can use variable with Single quotes as following :-

DECLARE @varName VARCHAR(50)
SET  @varName = '''word'''
SELECT @varName as colName

Output :- 'word'

Sample Fiddle

Upvotes: 2

Related Questions