Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Script to create a table
Message
 
 
À
22/03/2013 11:06:45
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01569044
Message ID:
01569046
Vues:
43
This is exactly what I did. And the result was as I described, step by step. And I was hoping I can combine it all in a more concise statement.
Thank you

>I do it this way....
>
>Go into SSMS and create everything the way I want it (tables. index, etc)
>Right-click on the table (or database) select "Script Table As...".
>Select the script type and destination
>
>
>
>>Hi,
>>
>>I am making a script for creating a new table (this script will be sent from VFP to the SQL Server). For starters I created the script in the SSMS. When SSMS creates the script it does it in several stages:
>>1. Creates table; e.g.
>>
>>create table [dbo].[MyTable] (
>>    [fld1]  [Int] Identity (1,1) not null,
>>    [fld2]  [char] (20 not null... 
>>and so on
>>
>>2.Create nonclustered index;e.g.
>>
>>CREATE NONCLUSTERED INDEX [IX_fld2] ON [dbo].[MyTable]
>>(
>>    [fld1] ASC 
>>and so on
>>
>>3. Create another nonclustered index (simimal to step 2 above)
>>4. Then next one and next one
>>5. Set default contraints for each field; e.g.
>>
>>alter table [dbo].[mytable] and constraint [df_fld2] default ('') for [fld2]
>>and so on for each field
>>
>>
>>My question is, can I do it all, creating structure, creating indexes, default constraints, in only statement? TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform