Author |
Topic |
dhani
Posting Yak Master
132 Posts |
Posted - 2009-01-02 : 12:51:56
|
Hello All,i have a big tables (many columns in it) and all of the column names was in UPPER CASE how can i change all the column names in lower case, since it is very huge number of columns & also many tables please suggest me other than manually changeingyour ideas highly appreciatePlease Help meBest Regardsdhani |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-02 : 12:54:08
|
didnt understand the intention of doing this. SQL server by default is case insensitive unless you're using a case sensitive collation. Does this have anything to do with your coiding standards? |
|
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-01-02 : 13:02:28
|
Hello Visakh,first of all, thank you for your response,quote: SQL server by default is case insensitive unless you're using a case sensitive collation
Yes, I DO accept this but it needs to be work in another tool to create reportsi have to do further reporting purpose i need to import all tables to that tool and reports from the toolso as per the standards it needs to be all lower case in that toolPlease help meBest Regardsdhani |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-01-02 : 13:10:56
|
he wants to update column names,use SP_RENAME for that and generate a SQL like Tara did. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-02 : 13:15:01
|
Yeah...i think sp_rename will do the job |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2009-01-02 : 13:23:23
|
Hmmm.. I was curiousI tried exec sp_rename 'TableName.ColumnName','columnname','column'and this works but is a bit manual.I tried exec sp_rename 'TableName.ColumnName',lower('ColumnName'),'column'but this didn't work. It spit out a syntax error.May still need to build a temp table from info schema...r&r |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-02 : 13:27:52
|
run taras posted code. copy result,paste to another window and execute. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
dhani
Posting Yak Master
132 Posts |
Posted - 2009-01-02 : 15:11:58
|
Hello TaraKizer,Thank you for your reply,i ran the below query quote: SELECT 'UPDATE ' + TABLE_NAME + ' SET ' + COLUMN_NAME + ' = LOWER(' + COLUMN_NAME + ')'FROM INFORMATION_SCHEMA.COLUMNS
copy result to new query window and execute.it says some records updated ......after that i refresh the DB and check the column names it is still in uppercaseCan you please give detailsBest Regardsdhani |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|