Showing posts with label names. Show all posts
Showing posts with label names. Show all posts

Sunday, February 19, 2012

Database Query

Is it possible to return the column names from the database using a SQL query,
what i need to do is
SELECT * FROM FEATURES WHERE 'VALUE' = 'YES'

i have a table which has a list of features and if they are selected i store the value yes, otherwise no . i want to be able to display a list of the features from the tables which have the value yes ! is this possible?yes xcept you dont need quotes around the column name..


SELECT * FROM FEATURES WHERE VALUE = 'YES'

hth|||Cheers but I worded the problem badly, VALUE isnt the name of the column, their are a number of different columns, each with different names, and i only want to display the column name if the value is yes ! any idea's?|||you wound then need to use CASE statement...check BOL for xact syntax but its something like


...
CASE
WHEN
colname='yes' then colname
ELSE NULL

hth|||what is BOL?|||BOL = Books Online

It is SQL Server's documentation.

database properties query

I've been asked to provide some information about databases on an sql server.

I can use the following query to provide the names of all the databases:

select * from master.dbo.sysdatabases

What I'm also looking to provide is the current "size" of the database. I'm trying to find a table that I can link to that would provide the database size. I can manually find this number by right clicking on the database from enterprise manager, selecting "properties" and picking it up from the general tab.

This is sql server 2K...

Thanks.look at sysfiles for each database ... that should get you started|||may be overkill, but check out the app in my sig.