SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Select Row contains values as 1
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

danasegarane76
Posting Yak Master

India
240 Posts

Posted - 08/28/2006 :  07:59:08  Show Profile  Send danasegarane76 an ICQ Message
Hi team,
I want to select a particular row where any fields name contains the value as 1.How can I.I am using vb as Front End and SQL server as back end.

chiragkhabaria
Flowing Fount of Yak Knowledge

India
1907 Posts

Posted - 08/28/2006 :  08:08:06  Show Profile  Visit chiragkhabaria's Homepage  Send chiragkhabaria a Yahoo! Message
Somthing like this
Select * from TableName Where
Field1 = 1 or Field2= 1 or...



Chirag
Go to Top of Page

danasegarane76
Posting Yak Master

India
240 Posts

Posted - 08/28/2006 :  08:12:08  Show Profile  Send danasegarane76 an ICQ Message
Dear chiragkhabaria,
Thanks for your reply.The table has more that 25 columns.So i need some general Module.Any field can have a value as 1.But I need to select the value of any of the fieldss.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
29910 Posts

Posted - 08/28/2006 :  08:14:42  Show Profile  Visit SwePeso's Homepage
Like this?
SELECT	Field1 f
FROM	TableName
WHERE	Field1 = 1
UNION
SELECT	Field2 f
FROM	TableName
WHERE	Field2 = 1
UNION
SELECT	Field3 f
FROM	TableName
WHERE	Field3 = 1
...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 08/28/2006 :  10:01:31  Show Profile  Send madhivanan a Yahoo! Message
Why do you have this requirement?
Is the table normalised?
http://www.datamodel.org/NormalizationRules.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000