Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 shortened SQL replacement for many fields

Author  Topic 

hcetiner
Starting Member

1 Post

Posted - 2010-08-14 : 15:53:14
I got an sql something like this.
I wantto set all Fields (Except 1st,2nd) to false
is there any short sql server code for this ?
maybe some for loop statement etc ?

graciâs

ie:
UPDATE TABLE1
SET
FIELD3=0,FIELD4=0,FIELD5=0,FIELD6=0,FIELD7=0,FIELD8=0,FIELD9=0,FIELD10=0,
FIELD11=0,FIELD12=0,FIELD13=0,FIELD14=0,FIELD15=0,FIELD16=0,FIELD17=0,FIELD18=0,FIELD19=0,
FIELD20=0,FIELD21=0,FIELD22=0,FIELD23=0,FIELD24=0,FIELD25=0,FIELD26=0,FIELD27=0,FIELD28=0,

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-15 : 03:36:20
you can make it short but you might need to use dynamic sql for that. so I feel what you have is much better.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -