Solved

How find value in any column?

Posted on 2007-11-30
2
231 Views
Last Modified: 2010-04-23
USE CompanyA SELECT * FROM EccUser WHERE Administrator='Y'

With that code, I can sql query the EccUser table for those with admin status. I am checking the Administrator column for Y values.

Is there a way to do a query on all columns for a specified value? Like this if it worked:

USE CompanyA SELECT * FROM EccUser WHERE 'Y'
0
Comment
Question by:Pizpot
2 Comments
 
LVL 9

Accepted Solution

by:
nito8300 earned 125 total points
ID: 20385161
Do you mean using a OR statement?

USE CompanyA SELECT * FROM EccUser WHERE columnA = 'Y' OR columnB = 'Y' OR columnC = 'Y'

Nito
0
 
LVL 8

Assisted Solution

by:i2mental
i2mental earned 125 total points
ID: 20385191
OR would be the most direct way. It is possible to create a loop through each of the columns using SYSCOLUMNS if this code had to be portable between tables or span multiple tables or perhaps had so many columns that it were more work to type every column name.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now