Reputation: 2278
i have a table like
id name
10 bob
20 bill
i want to select only name column in output with double quotes
like select '"'||name||'"' from table
it is giving me the correct output but is there any other way without using concatenation ...
Thank you..
Upvotes: 4
Views: 58344
Reputation: 1938
There are two scenarios you would want to use double quotes in sql in my opinion.
updating blog contents in columns which you cant edit in "edit top 200 rows"
so, if you want to use double quotes follow this.
SET QUOTED_IDENTIFIER OFF
BEGIN
DECLARE @YourSqlStmt AS VarChar(5000) -- Declare a variable.
SET @YourSqlStmt = "ok"
PRINT @YourSqlStmt -- do your operations here
END
This saves time and you need not to escape single quotes in a existing string content of the column.
Upvotes: 0
Reputation: 785
Using this you can get result with double quotes
' " ' + columnName + ' " '
Example
SELECT '"'+Name+'"' , Age
FROM customer
"Viranja" | 27
Upvotes: 9
Reputation: 1715
If your intention is to be able to "export" the result into space or comma-delimited text file, use a view to "format" your data. You will need to this for your date columns as well.
Upvotes: 0
Reputation: 22895
Create a virtual column that adds the quotes:
CREATE TABLE
....
quoted_name VARCHAR2 GENERATED ALWAYS AS ('"' || name || '"') VIRTUAL,
...
See here for more information:
http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php
Upvotes: 3
Reputation: 24046
this will check for any name with at least one double quote
select * from table
where name like '%"%'
Upvotes: 0