Jan Cichocki
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"."Fiel dName"
Changing the first letter of the table name to lower case would be a big plus. :)
Thanks!!!
"camelCaseTableName"."Fiel
Changing the first letter of the table name to lower case would be a big plus. :)
Thanks!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It is almost perfect now!
Here is what I have:
SELECT LOWER(LEFT(TABLE_NAME,1))+ SUBSTRING( TABLE_NAME ,2,LEN(TAB LE_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!!!
Here is what I have:
SELECT LOWER(LEFT(TABLE_NAME,1))+
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(TAB LE_NAME)-1 )+'.'+COLU MN_NAME AS FOO
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableName' AND TABLE_SCHEMA='Schema'
SELECT LOWER(LEFT(TABLE_NAME,1))+
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableName' AND TABLE_SCHEMA='Schema'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your the man. Thanks! Great time saver!!!
Final Example:
SELECT LOWER(LEFT(TABLE_NAME,1))+ SUBSTRING( TABLE_NAME ,2,LEN(TAB LE_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'
Final Example:
SELECT LOWER(LEFT(TABLE_NAME,1))+
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Change To Table Name' AND TABLE_SCHEMA='Change To Shema Name'
Your welcome sir !
OP is inactive
ASKER