|
-
Apr 28th, 2009, 12:22 PM
#1
Thread Starter
Lively Member
Simple Select Statement
Hi guys can you please take a look at this 
Below is my sample script
Code:
DECLARE @sku nvarchar(100)
SELECt @sku = sku from ac_orderItems where orderID = 12 and orderItemTypeID = 0
Print @sku
Then when i print @sku it give me a result of SampleB
but i want to produced an output of 'SampleB' enclosed in a single quote.
Thanks
-
Apr 28th, 2009, 01:23 PM
#2
Re: Simple Select Statement
 Originally Posted by hamtaro^-^
Hi guys can you please take a look at this
Below is my sample script
Code:
DECLARE @sku nvarchar(100)
SELECt @sku = sku from ac_orderItems where orderID = 12 and orderItemTypeID = 0
Print Chr(39) || @sku || chr(39)
Then when i print @sku it give me a result of SampleB
but i want to produced an output of 'SampleB' enclosed in a single quote.
Thanks
Will that work?
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Apr 28th, 2009, 02:28 PM
#3
Re: Simple Select Statement
For SQL Server change || to +
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 28th, 2009, 09:13 PM
#4
Re: Simple Select Statement
'chr' is not a recognized function name, use char instead.
Code:
Print char(39) + @sku + char(39)
-
Apr 29th, 2009, 12:37 AM
#5
Re: Simple Select Statement
SQL Server has a string function called QuoteName. The syntax is
QUOTENAME ( 'character_string' [ , 'quote_character' ] )
'quote_character' can be a single quotation mark ('), a left or right bracket ([] - default), or a double quotation mark (").
Code:
DECLARE @sku nvarchar(100)
SELECt @sku = QuoteName(sku,'''') from ac_orderItems where orderID = 12 and orderItemTypeID = 0
Print @sku
-
Apr 29th, 2009, 07:51 AM
#6
Re: Simple Select Statement
 Originally Posted by GaryMazzone
For SQL Server change || to +
 Originally Posted by dee-u
'chr' is not a recognized function name, use char instead.
Code:
Print char(39) + @sku + char(39)
This is how Microsoft confuses PL/SQL developers. 
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|