question

maheshembadi961 avatar image
maheshembadi961 asked

Is there any issues if we create NONCLUSTERED INDEXES in side a Stored procedure?

Is there any issues if we create NONCLUSTERED INDEXES in side a Stored procedure?

sql server 2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image
Kev Riley answered

Technically, no, there's no issue - be careful to check for the index existing on the table before you attempt to add it again though.

It's not the normal approach though, as it's a one-time operation, so why have this inside a stored procedure?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

maheshembadi961 avatar image
maheshembadi961 answered

@hi kev Riley,

thanks for your replay.

my stored procedure having multiple while loops it is taking more time to execute .so i have created indexes and drop that indexes after the query execution.

the while loops are mandatory to get report correctly shall i use this.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.