Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread listing all fields in a database depending on type
Thu, May 24 2012 9:26 PMPermanent Link

IQA

Hi Tim & Team,

This might be an out there question, but is it possible to list all
fieldnames in a database that are of a certain type.

For example I want to list all fieldnames and their respected table
names that are say 'float'

Reason I ask is, I have a large database and am converting all floats to
decimal with a scale of 2 and so want a list of the fields to I can make
an upgrade SQL script to update clients current data sets and saves
heaps of time manually going through each table and human error.

Thanks,

Phil.
Thu, May 24 2012 9:29 PMPermanent Link

IQA

I knew as soon as I asked the question, I'd find the answer...

Sorry all good.

select *
from information.tablecolumns
where type = 'float'
Sat, May 26 2012 1:43 AMPermanent Link

Adam Brett

Orixa Systems

Use an EDB SCRIPT with VAR for the COLUMN name & TABLE name & you can automate the whole process using FOR.

One of the best features of EDB, being able to make schema-wide changes by things like COLUMN TYPE & Name.
Fri, Jun 1 2012 12:49 AMPermanent Link

IQA

Would anyone have a basic script example, I'm trying to loop through
using the following query and DROP those columns...
SELECT TableName, Name, type
from information.tablecolumns
where type = 'float'

I've not used the SCRIPT language before so a kick start to do this
would get me rolling.

CHeers,

Phil

Fri, Jun 1 2012 3:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Phil


Have a look at the script I posted in the other thread in the general newsgroups (its your thread - migrate DBIASMV4 to ElevateDB (can field types be altered)

That one is altering the field types and messing with their properties a bit.The secon loops SELECT will need changing from

PREPARE flds FROM 'SELECT * FROM Information.TableColumns WHERE TableName = '''+tblName+'''';

to

PREPARE flds FROM 'SELECT * FROM Information.TableColumns WHERE TableName = '''+tblName+''' and  where type = 'float'';

The ALTER statement will change to DROP and that's about it

Roy Lambert [Team Elevate]
Sun, Jun 3 2012 7:11 AMPermanent Link

IQA

Thanks Roy, I should of thought of that. Worked a treat! Legend.
Image