Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to create a table with 180+ fields?
Message
De
28/05/2014 18:19:08
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008 R2
Application:
Web
Divers
Thread ID:
01600848
Message ID:
01600851
Vues:
48
>Hi
>I need to create a table with 2 character fields ( field1, field2 ) then fields of BIT type, default to 0 (false) , named
>[0501], [0502] [0503].....and up to [1029], [1030], [1031]
>Where 0501 represents May 1, etc... ( format mmdd)
>Is there some way to program sql server to build this?

Without trying to guess what you may want to do... I'd write a little prg. Using curly braces for textmerge as UT's pre tag reduces double lessthan and greaterthan to single ones (at least in preview).
c=""
ldDay=date(2000, 5, 1)
ldEnd=date(2000, 10, 31)
do while ldDay<= ldEnd
   lcF=right(dtos(ldday),4)
   ldday=ldDay+1
   c=c+textmerge(", [{{lcF}}] bit default 0 ")
enddo
text to _cliptext noshow textmerge
create table Blabla (field1 char(22), field2 char(34){{c}})
endtext

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform