0

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().

0

1 Answer 1

1

Nothing wrong with quick and easy short-cuts.

it just takes a bit of work. ;-)

See https://stackoverflow.com/questions/706664/generate-sql-create-scripts-for-existing-tables-with-query

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.