Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 24th, 2004, 06:27 AM
legrooch legrooch is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 legrooch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
if..else problem

Can someone help me?
I have this query

Code:
select *
from KA_STAN_ZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KA_STAN_ZABEZPIECZEN as dwa
Where jeden.nazwastacji = dwa.nazwastacji) and dc ='0'

I want to use If..Else for every column in my table. It contains 50 columns. I know that i must create 50 if..else.
But how to make one? I have a criteria for returning values.

For example:
if first_column_value >1 then
else first_column_value <1

I made this

Code:
Use sms_k3a
select *
from KA_STAN_ZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KA_STAN_ZABEZPIECZEN as dwa
Where jeden.nazwastacji = dwa.nazwastacji and ms = '1')
if KA_STAN_ZABEZPIECZEN.auditbaseobjects = '1'
begin
PRINT 'The following dc are excellent mod_cook books:'
PRINT ' '
select *
from KA_STAN_ZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KA_STAN_ZABEZPIECZEN as dwa
Where jeden.nazwastacji = dwa.nazwastacji and dc = '1')
End
else
if KA_STAN_ZABEZPIECZEN.auditbaseobjects = '0'
begin
select *
from KA_STAN_ZABEZPIECZEN as jeden
Where data = (SELECT DISTINCT MAX(data)
from KA_STAN_ZABEZPIECZEN as dwa
Where jeden.nazwastacji = dwa.nazwastacji and ms = '1')
end

sms_k3a is the name of database, KA_Stan_Zabezpieczen is the name of table and DC, nazwastacji and auditbaseobjects are the names of columns.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > if..else problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT