Solved

How find value in any column?

Posted on 2007-11-30
2
252 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

789 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