Wednesday, March 21, 2012

I cannot transfer column DEFAULT values from old table to new table

Hi all,
SQL 2000
I am doing :
SELECT *
INTO NewTable
FROM OldTable
WHERE 1 =0
The NewTable has the same :
column names, Data Type and Length BUT the column DEFAULT VALUES
don't get transferred , I always have te reenter them manually.
Does any one have a quick solution? Thanks a millionDefaults is a type of constraint, and those are not carried over with SELECT INTO. For this, you
have to script the table...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
<placidite1@.yahoo.com> wrote in message news:1178732983.525139.93780@.u30g2000hsc.googlegroups.com...
> Hi all,
> SQL 2000
> I am doing :
> SELECT *
> INTO NewTable
> FROM OldTable
> WHERE 1 =0
> The NewTable has the same :
> column names, Data Type and Length BUT the column DEFAULT VALUES
> don't get transferred , I always have te reenter them manually.
> Does any one have a quick solution? Thanks a million
>|||Thanks Mr Tibor Karaszi
I tried the SQL 2000 -> All Tasks -> Generate SQL Script on the table
formation
and it doesn't carry over the Default Constraint either...I have the
CREATE TABLE script, but
no default values.
Is there any tool within SQL 2000 that will do it (ie carry over the
default values)?
Thanks a million.
On May 9, 1:54 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> Defaults is a type of constraint, and those are not carried over with SELECT INTO. For this, you
> have to script thetable...
> --
> Tibor Karaszi,SQLServer MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
>
> <placidi...@.yahoo.com> wrote in messagenews:1178732983.525139.93780@.u30g2000hsc.googlegroups.com...
> > Hi all,
>
> >SQL2000
> > I am doing :
> > SELECT *
> > INTO NewTable
> > FROM OldTable
> > WHERE 1 =0
> > The NewTable has the same :
> >columnnames, Data Type and Length BUT thecolumnDEFAULTVALUES
> > don't get transferred , I always have te reenter them manually.
> > Does any one have a quick solution? Thanks a million- Hide quoted text -
> - Show quoted text -|||> I tried the SQL 2000 -> All Tasks -> Generate SQL Script on the table
> formation
You need to configure this to include constraints.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<placidite1@.yahoo.com> wrote in message
news:1178748995.880148.288630@.e65g2000hsc.googlegroups.com...
> Thanks Mr Tibor Karaszi
> I tried the SQL 2000 -> All Tasks -> Generate SQL Script on the table
> formation
> and it doesn't carry over the Default Constraint either...I have the
> CREATE TABLE script, but
> no default values.
> Is there any tool within SQL 2000 that will do it (ie carry over the
> default values)?
> Thanks a million.
>
> On May 9, 1:54 pm, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
>> Defaults is a type of constraint, and those are not carried over with SELECT INTO. For this, you
>> have to script thetable...
>> --
>> Tibor Karaszi,SQLServer
>> MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
>>
>> <placidi...@.yahoo.com> wrote in
>> messagenews:1178732983.525139.93780@.u30g2000hsc.googlegroups.com...
>> > Hi all,
>> >SQL2000
>> > I am doing :
>> > SELECT *
>> > INTO NewTable
>> > FROM OldTable
>> > WHERE 1 =0
>> > The NewTable has the same :
>> >columnnames, Data Type and Length BUT thecolumnDEFAULTVALUES
>> > don't get transferred , I always have te reenter them manually.
>> > Does any one have a quick solution? Thanks a million- Hide quoted text -
>> - Show quoted text -
>

No comments:

Post a Comment