Aracılığıyla paylaş


GenerateSQL yöntemi (dizin)

Bu özellik Microsoft SQL Server'ın ilerideki bir sürümünde kaldırılacaktır. Yeni geliştirme işlerinde bu özelliği kullanmaktan kaçının ve bu özelliği kullanmakta olan uygulamalarda değişiklik yapmayı planlayın.

The GenerateSQL method returns a string that contains a Transact-SQL command batch used to create the Microsoft SQL Server index defined by the properties of the Index object used.

Sözdizimi

object
.GenerateSQL(
Table
)
as
String

Bölümleri

  • nesne
    Bir nesneye uygulanan listesinde değerlendirir ifade.

  • Tablo
    Bir sql Dağıtılmış Yönetim Nesneleri (sql-dmo) değerlendirir bir deyim Table nesne.

Prototip (c/C++)

HRESULT GenerateSQL(
LPSQLDMOTABLE pTable,
SQLDMO_LPBSTR pRetVal);

Not

sql-dmo dizeleri her zaman ole bstr döndürülür.c/C++ uygulama dize bir başvuru alır.Uygulama başvurusu kullanarak serbest bırakmanız gerekir SysFreeString.

Döndürür

Transact-sql komutu toplu iş iş olarak bir dize.

Açıklamalar

Kullanın GenerateSQL veya GenerateCreationSQL yöntem oluşturma komutu toplu iş iş kullanılmak üzere başka bir işlem.For example, to define a new index, capture the command batch using the GenerateSQL or GenerateCreationSQLmethod, and then use the command batch to create a job step for scheduled index creation.

İçin Index nesnesi, GenerateSQL ve GenerateCreationSQL gerçekleþtirmek benzer işlevler.Komut dosyası tarafından döndürülen GenerateSQL yöntem içeren bir Transact-sql deyim oluşturma bir dizin.The GenerateCreationSQL method prefixes the index creation statement with Transact-SQL syntax that conditionally removes an existing index.

GenerateSQL veya GenerateCreationSQL yöntem kullanmak için

  1. Yeni bir oluşturmak Index nesne.

  2. Set Name özellik.

  3. Set IndexedColumns özellik; hedef sütunlar başvuru tablo adı ile.

  4. Dizin gibi tanımlayan ek özellikleri ayarlamak FileGroup ve Type.

  5. Al Table Başvuran hedef nesne tablo dan Tables koleksiyonu.

  6. Döndürülen metin yakalama Transact-sql komutu toplu iş iş oluşturur yöntem çağırın.

    Önemli notÖnemli

    The GenerateSQL and GenerateCreationSQLmethods generate a Transact-SQL batch used to create an index.Yöntem başarısız olur, Index kullanılan başvuru nesnesi bir varolan sql Server dizin.Use Script yöntem, Index nesne oluşturma Transact-sql komutu toplu iş iş tanımlayan varolan bir dizini.

İçin geçerlidir: