Showing posts with label import. Show all posts
Showing posts with label import. Show all posts

Friday, March 23, 2012

how to change dts import/export windows size

Howdy!
Does any of you good folk know how to change window size of the DTS
Import/Export Wizard window?
Darn thing is very small and inconvinient to work with, no apparent way to
change it's size,
may be there is a registry tweak or something.
Thanks in advance,
I.B.Yes, It's inconvenient. No, there is no way to change the size of it, as
far as I know. Maybe in MS SQL SERVER 2004?
Best regards,
Chuck Conover
www.TechnicalVideos.net

"Ilya Bari" <IBari@.SnappyDsl.net> wrote in message
news:4015c5fd@.news.snappydsl.net...
> Howdy!
> Does any of you good folk know how to change window size of the DTS
> Import/Export Wizard window?
> Darn thing is very small and inconvinient to work with, no apparent way to
> change it's size,
> may be there is a registry tweak or something.
> Thanks in advance,
> I.B.

Friday, February 24, 2012

How to by pass this error message

Hi,

I am trying to import transfer data from one database(sqlserver) to another database(sqlserver)...

But when i run the stored procedure... it gives me the following error

Msg 2627, Level 14, State 1, Procedure usp_ImportFunds_Growthof10K, Line 36

Violation of PRIMARY KEY constraint 'PK_Growthof10K'. Cannot insert duplicate key in object 'Growthof10K'.

and this is my sproc

Code Snippet

USE [StageFiserv_Dev]

GO

/****** Object: StoredProcedure [dbo].[usp_ImportFunds_Growthof10K] Script Date: 08/10/2007 12:53:48 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER Procedure [dbo].[usp_ImportFunds_Growthof10K]

AS

BEGIN

DECLARE @.Count int

SET NOCOUNT ON;

UPDATE Fiserv_Dev..Growthof10K

SET

ChartHeader = g.ChartHeader,

Dates = Substring(g.Dates,1,9),

NAV = g.NAV,

LastChangeDate = GetDate()

FROM

Fiserv_Dev..Growthof10K gk

Join [Growth] g ON gk.Cusip = g.Cusip

Where

gk.ChartHeader <> g.ChartHeader

OR

gk.Dates <> Substring(g.Dates,1,9)

OR

gk.NAV <> g.NAV

SET @.Count = @.@.ROWCOUNT

IF @.Count > 0

RAISERROR('Updated %d records(s) in Growthof10K.', 0, 1, @.Count) WITH NOWAIT

ELSE

RAISERROR('No changes made Growthof10K.', 0, 1) WITH NOWAIT

RAISERROR('Adding records to Growthof10K.',0,1) With NOWAIT

INSERT INTO Fiserv_Dev..Growthof10K

(

Cusip,

ChartHeader,

Dates,

NAV

)

SELECT

g.Cusip,

g.ChartHeader,

Substring(g.Dates,1,9),

g.NAV

FROM

Growth g

Where

NOT Exists (

Select *

FROM

Fiserv_Dev..Growthof10K gk

Where

gk.Cusip = g.Cusip

)

SET @.Count = @.@.ROWCOUNT

IF @.Count > 0

RAISERROR('Added %d records(s) to Growthof10K table.', 0, 1, @.Count) WITH NOWAIT

ELSE

RAISERROR('No records added to Growthof10K table.', 0, 1) WITH NOWAIT

SET NOCOUNT OFF

END

There around 763 records in the growth table

Can some one please help me.

Regards,

Karen

Karen

You are inserting a duplicate value in a primary key. You can't do that. Delete the duplicate values for the primary key field or remove the primary key constraint.

|||

thanks...|||

Did this solve your problem? If so then please mark it as answer.

How to Bulk Insert string data into a money colum?

How to Bulk Insert string data into a money colum?

Format files work great to import string data into a char column.

But I cannot convert a char column to either a money or numeric data type.

I get datatype errors when bulk inserting string data into a money column.

The string data is 22 characters long, no decimal point, trailing negative sign.

Here is an example: 000000000000007898384-

My goal: Bulk Insert the above sample string into a money column.

Often, for situations like this, it is useful to first import into a 'staging' table (same datatypes as import data),

AND then execute 'clean-up' routines

BEFORE moving the data into the production tables.

This allows correcting alot of data anomolies that cannot be handled with a format file.

|||

Thanks, Arnie, for the quick response. What clean-up routines did you have in mind?

Using Enterprise Manager to change the destination column's data type from "char" to "money" or "int" won't work.

Are you talking about concatenating a decimal point to the end of the source string, in hopes that the decimal point will help me get past the conversion issue?

|||

John,

Something like this could work for your situation:

Code Snippet


DECLARE
@.MyString varchar(25),
@.MyMoney money


SET @.MyString = '000000000000007898384-'


IF right( @.MyString, 1 ) = '-'
SET @.MyMoney = cast( ( '-' + left( @.MyString, ( len( @.MyString ) - 1 ))) AS money )
ELSE
SET @.MyMoney = cast( @.MyString AS money )


SELECT @.MyMoney


-7898384.0000

|||

So, it looks like you're putting the negative sign at the front as needed and leaving the positive numbers alone, before casting the result as money. This is fine.

My SQL table has 23 columns and millions of rows.

Column 10 is char, 22 characters wide. Negative signs are trailing.

How would I apply the code to all the rows of column 10 in that table?

|||

You would build a CASE structure (something like this):


DECLARE @.MyTable table
( RowID int IDENTITY,
Column10 varchar(50)
)


INSERT INTO @.MyTable VALUES ( '000000000000007898384-' )
INSERT INTO @.MyTable VALUES ( '000000000000007898385' )


SELECT
RowID,
MyMoney = cast( stuff( CASE
WHEN right( Column10, 1 ) = '-'
THEN ( '-' + left( Column10, ( len( Column10 ) - 1 )))
ELSE Column10
END
, len( CASE
WHEN right( Column10, 1 ) = '-'
THEN ( '-' + left( Column10, ( len( Column10 ) - 1 )))
ELSE Column10
END ) -1
, 0, '.' ) AS money )
FROM @.MyTable


RowID MyMoney
--
1 -78983.8400
2 78983.8500

For illustration purposes, I've also added a decimal point two places from the right. If you don't need that, then remove the STUFF() function. (I thought that just 'might' come up next...)

You 'should' be able to use a query like this to INSERT the staging table data into your production table.

|||

Ok, Arnie, I'll give it a shot. Thanks again.

John

|||

My brain wasn't operating on all cylinders this morning.

You can do without the STUFF() function -just divide by 100 if you need the partial money, remove the [ / 100 ] if you have whole money.

Code Snippet


SELECT
RowID,
MyMoney = cast( CASE
WHEN right( Column10, 1 ) = '-'
THEN ( '-' + left( Column10, ( len( Column10 ) - 1 )))
ELSE Column10
END AS money ) / 100

FROM @.MyTable

|||This is great, Arnie, thanks.

Sunday, February 19, 2012

How to build a script to extract 5% of the production Database dat

Hi, all
How to build a script to extract 5% of the production Database data to
development DB? Normally, I use DTS import/export to do that table by table
( use select top 500 * from theTable). Is there a better way? Our Production
DB is so big, I want to give some simple data to development DB for test.
Thanks for any help!
Brian
Try SELECT TOP 5 PERCENT instead.
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Brian" <Brian@.discussions.microsoft.com> wrote in message
news:CFE57E50-21F6-41D9-B227-61411F066EC1@.microsoft.com...
Hi, all
How to build a script to extract 5% of the production Database data to
development DB? Normally, I use DTS import/export to do that table by table
( use select top 500 * from theTable). Is there a better way? Our
Production
DB is so big, I want to give some simple data to development DB for test.
Thanks for any help!
Brian
|||This really is not a feasible task to accomplish in any generic manner. You
will need to factor in the relationships (defined or assumed) between the
tables before you can begin to address what some random percentage of the
database really means. As a simple example, do you want want to pull a
random 5% of the rows in an order table without also pulling ALL of the
associated order_detail rows (and we'll ignore all of the other
related/required rows - customers, products, addresses, etc.).
Usually, there is some basic set of information that is required for any
system to work correctly - you'll need 100% of this information (e.g.,
you'll need all of the GL accounts before you can pull ANY activity for
these accounts).
"Brian" <Brian@.discussions.microsoft.com> wrote in message
news:CFE57E50-21F6-41D9-B227-61411F066EC1@.microsoft.com...
> Hi, all
> How to build a script to extract 5% of the production Database data to
> development DB? Normally, I use DTS import/export to do that table by
table
> ( use select top 500 * from theTable). Is there a better way? Our
Production
> DB is so big, I want to give some simple data to development DB for test.
> Thanks for any help!
> Brian

How to build a script to extract 5% of the production Database dat

Hi, all
How to build a script to extract 5% of the production Database data to
development DB? Normally, I use DTS import/export to do that table by table
( use select top 500 * from theTable). Is there a better way? Our Productio
n
DB is so big, I want to give some simple data to development DB for test.
Thanks for any help!
BrianTry SELECT TOP 5 PERCENT instead.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Brian" <Brian@.discussions.microsoft.com> wrote in message
news:CFE57E50-21F6-41D9-B227-61411F066EC1@.microsoft.com...
Hi, all
How to build a script to extract 5% of the production Database data to
development DB? Normally, I use DTS import/export to do that table by table
( use select top 500 * from theTable). Is there a better way? Our
Production
DB is so big, I want to give some simple data to development DB for test.
Thanks for any help!
Brian|||This really is not a feasible task to accomplish in any generic manner. You
will need to factor in the relationships (defined or assumed) between the
tables before you can begin to address what some random percentage of the
database really means. As a simple example, do you want want to pull a
random 5% of the rows in an order table without also pulling ALL of the
associated order_detail rows (and we'll ignore all of the other
related/required rows - customers, products, addresses, etc.).
Usually, there is some basic set of information that is required for any
system to work correctly - you'll need 100% of this information (e.g.,
you'll need all of the GL accounts before you can pull ANY activity for
these accounts).
"Brian" <Brian@.discussions.microsoft.com> wrote in message
news:CFE57E50-21F6-41D9-B227-61411F066EC1@.microsoft.com...
> Hi, all
> How to build a script to extract 5% of the production Database data to
> development DB? Normally, I use DTS import/export to do that table by
table
> ( use select top 500 * from theTable). Is there a better way? Our
Production
> DB is so big, I want to give some simple data to development DB for test.
> Thanks for any help!
> Brian

How to build a script to extract 5% of the production Database dat

Hi, all
How to build a script to extract 5% of the production Database data to
development DB? Normally, I use DTS import/export to do that table by table
( use select top 500 * from theTable). Is there a better way? Our Production
DB is so big, I want to give some simple data to development DB for test.
Thanks for any help!
BrianTry SELECT TOP 5 PERCENT instead.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Brian" <Brian@.discussions.microsoft.com> wrote in message
news:CFE57E50-21F6-41D9-B227-61411F066EC1@.microsoft.com...
Hi, all
How to build a script to extract 5% of the production Database data to
development DB? Normally, I use DTS import/export to do that table by table
( use select top 500 * from theTable). Is there a better way? Our
Production
DB is so big, I want to give some simple data to development DB for test.
Thanks for any help!
Brian|||This really is not a feasible task to accomplish in any generic manner. You
will need to factor in the relationships (defined or assumed) between the
tables before you can begin to address what some random percentage of the
database really means. As a simple example, do you want want to pull a
random 5% of the rows in an order table without also pulling ALL of the
associated order_detail rows (and we'll ignore all of the other
related/required rows - customers, products, addresses, etc.).
Usually, there is some basic set of information that is required for any
system to work correctly - you'll need 100% of this information (e.g.,
you'll need all of the GL accounts before you can pull ANY activity for
these accounts).
"Brian" <Brian@.discussions.microsoft.com> wrote in message
news:CFE57E50-21F6-41D9-B227-61411F066EC1@.microsoft.com...
> Hi, all
> How to build a script to extract 5% of the production Database data to
> development DB? Normally, I use DTS import/export to do that table by
table
> ( use select top 500 * from theTable). Is there a better way? Our
Production
> DB is so big, I want to give some simple data to development DB for test.
> Thanks for any help!
> Brian