Solved

How find value in any column?

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

773 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