Link to home
Start Free TrialLog in
Avatar of Jan Cichocki
Jan CichockiFlag for United States of America

asked on

Cut and paste SQL results into C# app... "camelCaseTableName"."FieldName"

How would I write a query in MS SQL that lists all the fields in a table in the following format:

"camelCaseTableName"."FieldName"

Changing the first letter of the table name to lower case would be a big plus.  :)

Thanks!!!
ASKER CERTIFIED SOLUTION
Avatar of Flabio Gates
Flabio Gates

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
Avatar of Jan Cichocki

ASKER

Fantastic!  Thank you for your quick response!
It is almost perfect now!

Here is what I have:

SELECT LOWER(LEFT(TABLE_NAME,1))+SUBSTRING(TABLE_NAME,2,LEN(TABLE_NAME))+'.'+COLUMN_NAME AS FOO
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableName' AND TABLE_SCHEMA='Schema'

I am getting a plural version of the table and would like to trim off the last character of the table name...  Would you be so kind as to show me how to trim one character off the end of the table name to eliminate the "s" on my table name.  My SQL is limited...  :)

I have tables.field

and would like

table.field

Thanks again!!!
Pls try ...

SELECT LOWER(LEFT(TABLE_NAME,1))+SUBSTRING(TABLE_NAME,2,LEN(TABLE_NAME)-1)+'.'+COLUMN_NAME AS FOO
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableName' AND TABLE_SCHEMA='Schema'
SOLUTION
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
Your the man.  Thanks!  Great time saver!!!

Final Example:
SELECT LOWER(LEFT(TABLE_NAME,1))+SUBSTRING(TABLE_NAME,2,LEN(TABLE_NAME) - 2)+'.'+COLUMN_NAME AS FOO , TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Change To Table Name' AND TABLE_SCHEMA='Change To Shema Name'
Your welcome sir !
Avatar of Flabio Gates
Flabio Gates

OP is inactive