Create Index - Pls Help



hi all

Here am using "Use Database" keyword, as the connection string will
contain a different Initial Catalog

Pls let me know is there any Technical issues to execute this query
(Its working fine-)

Public Function GenerateCreateIndexQuery(ByVal TableName As String, _
ByVal IndexName As String, ByVal ColName As
String, _
ByVal dataBaseName As String)

Dim sqlStr As String

sqlStr = "USE " & dataBaseName & " IF EXISTS (SELECT name FROM
sysindexes WHERE name = '" & IndexName & "')"
sqlStr = sqlStr & " DROP INDEX " & TableName & "." & IndexName
sqlStr = sqlStr & " USE " & dataBaseName & " CREATE INDEX " &
IndexName & " ON "
sqlStr = sqlStr & TableName & "(" & ColName & ")"
Return sqlStr

End Function

.



Relevant Pages