Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

How to escape alias names for Oracle query

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)
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial