How to escape alias names for Oracle query

brgdotnet
brgdotnet used Ask the Experts™
on
I have some inline sql that will be run against sql server and Oracle. If it were strictly sql server I could surround my alias names with square brackets and the query will work against sql server. However it will not work against Oracle. So in order to make the query work against Oracle as well, I need to
surround my alias names with double quotes. So the below works against sql server, but still does not work against Oracle. So can someone suggest an alternate way to escape my alias names with double quotes, because the below does not work when i run it against Oracle.


const string mySql = "SELECT bt.UNIQUE_ID AS \"Client Unique Id\" FROM tbl_Cust_Table bt"

SqlCommand theCommand = new SqlCommand();
theCommand.CommandText = mySql
var parameter = theCommand.CreateParameter();
parameter.ParameterName = "@0";
parameter.DbType = DbType.Stringl
parameter.Value = inValue;
theCommand.Parameters.Add(parameter)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
Commented:
Somewhere I met something like:

string query = @"select colName as ""alias1"" from tblName;";

Open in new window


Can't try as do not have Oracle DB under hands :).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial