Showing posts with label names. Show all posts
Showing posts with label names. Show all posts

Wednesday, March 7, 2012

DTS of data between two tables, same field names but differnt datatypes

I need to migrate data from one sql database to another. The second DB
is a newer version of the "old" database with mostly the same tables
and fieldnames. In order support some reporting queries in the "new"
version I needed to change the datatype of a few fields from varchar to
int(the data stored was integers already as they were lookup tables).

DTS works great except in the cases of about 10 fields which I changed
the datatypes on from varchar to int.

DTS seems to drop the data if the fieldname and datatype are not an
exact match. Is there any way to use DTS and have it copy data from a
field call subsid type varchar to a field call subsid type int?<tdmailbox@.yahoo.com> wrote in message
news:1115388735.044389.231150@.g14g2000cwa.googlegr oups.com...
>I need to migrate data from one sql database to another. The second DB
> is a newer version of the "old" database with mostly the same tables
> and fieldnames. In order support some reporting queries in the "new"
> version I needed to change the datatype of a few fields from varchar to
> int(the data stored was integers already as they were lookup tables).
> DTS works great except in the cases of about 10 fields which I changed
> the datatypes on from varchar to int.
> DTS seems to drop the data if the fieldname and datatype are not an
> exact match. Is there any way to use DTS and have it copy data from a
> field call subsid type varchar to a field call subsid type int?

This should work fine - I tested it quickly on two tables with the same
column name but the source being varchar(10) and the destination int. Using
a Transform Data Task worked correctly, and the mapping was handled
automatically.

I'm not sure what you mean by DTS seems to "drop the data". Perhaps you can
give some more information - your MSSQL version, which type of task you're
using to move the data, the DDL for the tables, any error messages etc.

Simon|||DTS copies all the columns except the ones with datatype changes. My
varchars to ints end up with empty ints in the desitnation table.

SQL 2000, DTS export, no error messages.|||I tested it again with the export wizard (I'd used the package designer
before), and it worked fine. I have no idea why it's not working for
you, unless you have a column transformation of some sort. One other
guess would be that your values are too big for an int, and you've also
set ANSI_WARNINGS OFF, which would ignore the overflow. But since
that's ON for ODBC/OLE DB by default, it's very unlikely.

You could specify a source query instead of a source table and use CAST
to force the conversion:

select col1, col2, cast(col3 as int), col4...
from dbo.SourceTable

Even if that doesn't work, you might get a clue of some sort from an
error. Finally, you could also copy the data into a staging table which
has exactly the same structure as the source table, then use SQL to
check and INSERT the data. Or just INSERT directly, if both databases
are on the same server.

Simon

Friday, February 17, 2012

DTS import renames my SPs to previous names

I am using SQL Server 7 SP4.

I have created a blank database in which i am trying to import using DTS
wizard all tables/views/stored procedures without any DATA (records).

I keep getting different errors when importing the views and/or the SPs.
I've tried many things unsuccessfully.

Now even after the error msg of the DTS, i see some of the SPs under
their previous names.

In other words, let's say i have an SP called zprocDeleteProduct and
this SP was previously called procDeleteProduct.

When i check the 2nd database, i see the SP as zprocDeleteProduct
instead of seeing it as procDeleteProduct.

I have other SPs that are being imported with their previous names.

I have renamed these SPs from within Access XP. I don't create SPs
in SQL EM or SQL Query Analyzer.

How can i fix this problem? I don't want to import SPs under their previous
names.

Thank youOpen query analyzer, and execute "sp_helptext zprocDeleteProduct" (or
procDeleteProduct). the output will be the text of the SP. The name
that appears immediatley after the "CREATE PROCEDURE" is the name your
SPs will be imported as. may also want to check your sysobjects table
to verify that names match.
FYI - MS Access isn't "a handy tool to administer SQL Server". Use
Query Analyzer as much as possible, use MMC (Enterprise Manager) as
SELDOM as possible, and use Access never. :-)
Alexey

"serge" <sergea@.nospam.ehmail.com> wrote in message news:<JoUcb.6681$1H3.465640@.news20.bellglobal.com>...
> I am using SQL Server 7 SP4.
> I have created a blank database in which i am trying to import using DTS
> wizard all tables/views/stored procedures without any DATA (records).
> I keep getting different errors when importing the views and/or the SPs.
> I've tried many things unsuccessfully.
> Now even after the error msg of the DTS, i see some of the SPs under
> their previous names.
> In other words, let's say i have an SP called zprocDeleteProduct and
> this SP was previously called procDeleteProduct.
> When i check the 2nd database, i see the SP as zprocDeleteProduct
> instead of seeing it as procDeleteProduct.
> I have other SPs that are being imported with their previous names.
> I have renamed these SPs from within Access XP. I don't create SPs
> in SQL EM or SQL Query Analyzer.
> How can i fix this problem? I don't want to import SPs under their previous
> names.
> Thank you|||Oh, and by the way - if you are transferring objects without data -
use the "Generate SQL Script" wizard in Enterprise Manager, then run
that script in Query Analyzer on the target database. DTS is useful
for data migration, not object migration.
Alexey

"serge" <sergea@.nospam.ehmail.com> wrote in message news:<JoUcb.6681$1H3.465640@.news20.bellglobal.com>...
> I am using SQL Server 7 SP4.
> I have created a blank database in which i am trying to import using DTS
> wizard all tables/views/stored procedures without any DATA (records).
> I keep getting different errors when importing the views and/or the SPs.
> I've tried many things unsuccessfully.
> Now even after the error msg of the DTS, i see some of the SPs under
> their previous names.
> In other words, let's say i have an SP called zprocDeleteProduct and
> this SP was previously called procDeleteProduct.
> When i check the 2nd database, i see the SP as zprocDeleteProduct
> instead of seeing it as procDeleteProduct.
> I have other SPs that are being imported with their previous names.
> I have renamed these SPs from within Access XP. I don't create SPs
> in SQL EM or SQL Query Analyzer.
> How can i fix this problem? I don't want to import SPs under their previous
> names.
> Thank you|||I will use the Query Analyzer to transfer the scripts instead of DTS.

Thanks Alexey

"Alexey Aksyonenko" <Alexey.Aksyonenko@.coanetwork.com> wrote in message
news:1449e414.0309260637.6840efa@.posting.google.co m...
> Oh, and by the way - if you are transferring objects without data -
> use the "Generate SQL Script" wizard in Enterprise Manager, then run
> that script in Query Analyzer on the target database. DTS is useful
> for data migration, not object migration.
> Alexey