Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL equvilant of copy structure
Message
De
17/09/2001 10:31:15
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00557214
Message ID:
00557282
Vues:
11
>Does anybody know what the best way of creating a new SQL Server table with indexes from the structure of an existing SQL Server table?
>
>I guess the commands would be similar to COPY STRUCTURE but using SQLEXEC(), but being a SQL novice, I am stuck.
>
>Any help would be gratefully appreciated.
>
>Justin.

You can script your database objects using SQL-DMO, and then run them on your target database like so:
oSql = Create("sqldmo.sqlserver")
oSql.Connect("(local)")  && insert connection params here
oDB = oSql.Databases("mySourceDB")
cTbl = oDB.Tables("myTable").Script(4)  && 4 = SQLDMOScript_Default
oDB = oSql.Databases("myTargetDB")  && Connect to target DB
oDB.ExecuteImmediate(cTbl)  && Run script on target DB
To include other table properties in the script check out the constants for the Script method in SQL books online or on MSDN online.

HTH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform