I tried:
Select * Into <DestinationTableName> From <SourceTableName> Where 1 = 2
but the default value constraint is not created.
I have a smalldatetime
column whose default value is getdate()
.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityNothing wrong with quick and easy short-cuts.
it just takes a bit of work. ;-)
Create a user defined function using the code from the link, then you can exec the output...
snip...
select @tsql = dbo.udf_GenerateTableCreateScript(N'dbo.mytable')
exec @tsql