Hi Guys,
Just wondering if anyone knows how to copy a SQL Table into the same
database, whilst still maintaining all if its extended properties.
I tried migrating from Access XP with different table name in Access,
however it doesn't like it with regard to ext. properties, indexes, etc.
Thanks
MarkWhile generating scipts in Enterprise Manager, there's an option in the
'Formatting' tab to script extended properties.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"MarkCapo" <MarkCapo@.discussions.microsoft.com> wrote in message
news:CFDF46ED-0976-4F84-A8D0-A28BA0655710@.microsoft.com...
Hi Guys,
Just wondering if anyone knows how to copy a SQL Table into the same
database, whilst still maintaining all if its extended properties.
I tried migrating from Access XP with different table name in Access,
however it doesn't like it with regard to ext. properties, indexes, etc.
Thanks
Mark|||Mark
SELECT <column list> INTO NewTable FROM OldTable
Note : If you want to copy table with the data you can add WHERE 1=1
otherwise add WHERE 1=2
Also this tecnique does not move PK,FK ,Idenity Property. Check it out.
"MarkCapo" <MarkCapo@.discussions.microsoft.com> wrote in message
news:CFDF46ED-0976-4F84-A8D0-A28BA0655710@.microsoft.com...
> Hi Guys,
> Just wondering if anyone knows how to copy a SQL Table into the same
> database, whilst still maintaining all if its extended properties.
> I tried migrating from Access XP with different table name in Access,
> however it doesn't like it with regard to ext. properties, indexes, etc.
> Thanks
> Mark|||Just a small correction. If the original table has an identity column,
then the new table will also have it. In any case since the original
question was how to create the table with all of its properties (I
guess that by properties he meant constraints), select into is not a
good option.
Adi|||Thanks
CREATE TABLE t1
(
col INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
)
INSERT t1 DEFAULT VALUES
IF OBJECTPROPERTY ( object_id('t1'),'TABLEHASIDENTITY') = 1
print 'Yes'
GO
SELECT * INTO t2 FROM t1
IF OBJECTPROPERTY ( object_id('t2'),'TABLEHASIDENTITY') = 1
print 'Yes'
GO
"Adi" <adico@.clalit.org.il> wrote in message
news:1116850585.889504.289900@.g14g2000cwa.googlegroups.com...
> Just a small correction. If the original table has an identity column,
> then the new table will also have it. In any case since the original
> question was how to create the table with all of its properties (I
> guess that by properties he meant constraints), select into is not a
> good option.
> Adi
>
Sunday, February 19, 2012
Copy Table with new Name in same Database
Labels:
copy,
database,
extended,
guys,
knows,
maintaining,
microsoft,
mysql,
oracle,
properties,
samedatabase,
server,
sql,
table,
whilst
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment