You can generate scripts to a file via SQL Server Management Studio, here are the steps:
- Right click the database you want to generate scripts for (not the table) and select tasks – generate scripts
- Next, select the requested table/tables, views, stored procedures, etc (from select specific database objects)
- Click advanced – select the types of data to script
- Click Next and finish
MSDN Generate Scripts
When generating the scripts, there is an area that will allow you to script, constraints, keys, etc. From SQL Server 2008 R2 there is an Advanced Option under scripting:
