Core component of SQL Server for storing, processing, and securing data
You can also go to Tools->Options and SQL Server Object Explorer->Scripting->Table and View options to select that indexes should be scripted.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to create a create table script for existing table with indexes
Core component of SQL Server for storing, processing, and securing data
You can also go to Tools->Options and SQL Server Object Explorer->Scripting->Table and View options to select that indexes should be scripted.
Just right click and Generate Script does not give index details. Hence I will always recommend to use Wizard option - use Task -> Generate Script -> Advanced -> set Index options, triggers to true and then generate the script. The generated script will be the one to be used to create an identical Table or any object as per the source database.
To create a CREATE TABLE script for an existing table in SQL Server, you can use SQL Server Management Studio (SSMS) to generate the script. Here are the steps:
CREATE TABLE script for the selected table, including its structure and indexes.This method allows you to easily obtain the complete definition of the table, including any indexes that are associated with it.
References: