Showing posts with label spreadsheet. Show all posts
Showing posts with label spreadsheet. Show all posts

Tuesday, March 27, 2012

DTS question - need your help!

I am trying to use DTS load Excel data to SQL Server

The Excel Spreadsheet has 100 columns in each row. Let say I have 3 rows in Excel sheet.
Each row has 100 columns as follows,

column1, column2, ...column100

Now I want to load it to a table which has only one column.

The first record will be the column1 of the first row from the excel spreadsheet
The second record will be the column2 of the first row from the excel spreadsheet
...
The 100th record will be the column100 of the first row from the excel spreadsheet

The 101th record will be the column1 of the second row from the excel spreadsheet
...

Can anyone give me a suggections? Thanks in advance,

PeterHmm, any way you can transpose the columns in Excel? I can't think of a simple way to create an SQL Statement to transpose the columns in DTS. It might be easier to manipulate Excel, rather than trying to do the transpose in DTS.|||I agree with the first post, but you could do it starting with DTS. Suck the excel sheet into a 'holding' table and then run a stored procedure that takes each cell and makes it a record by itself. You could use a cursor to step through the records and do 100 inserts to the final table for each row in the holding table.|||Is the order truyly that important?

You can get all the data in one column by using the following SQL statement instead of a table as your source:

SELECT Column1
FROM [Sheet1$]
UNION ALL
SELECT Column2
FROM [Sheet1$]
UNION ALL
SELECT Column3
FROM [Sheet1$]
...

You'll need a lot of cut and past (or a handy little script) to generate all the UNIONed selects.

If the order truly is important, then I'd add another column to your spreadsheet for the row number. Import the entire spreadsheet into the a temp table using something like this:

SELECT TheValue = Column1,
TheRow = RowNumber, -- your row number column
TheColumn = 1
FROM [Sheet1$]
UNION ALL
...

Increment the column number for each column. Again, a script will write this monster select for you. Then you can insert into your final table:

INSERT ...
SELECT TheValue
FROM MyTempImportTable
ORDER by TheRow ASC, TheColumn ASC

FYI - You may need to use UNION rather than UNION ALL. I don't recall the exact workings of EXCEL with respect to the ALL part. A little experimenting (or a syntax) error should clear it up pretty quickly.

DTS question

I have a dts package which I built which I will call Package1. Package1
imports data from an excel spreadsheet into SQL Server 2000. The only thing
that changes about Package1 is the excel input file name. How can I call th
e
package from VB .Net and feed the new excel file name into the call from VB
.Net?
Thanks.
ArcherSee if this helps, look for "Using Connections":
Working with files and the FileSystemObject
http://www.sqldts.com/default.aspx?292
AMB
"bagman3rd" wrote:

> I have a dts package which I built which I will call Package1. Package1
> imports data from an excel spreadsheet into SQL Server 2000. The only thi
ng
> that changes about Package1 is the excel input file name. How can I call
the
> package from VB .Net and feed the new excel file name into the call from V
B
> .Net?
> Thanks.
> Archer

DTS QUERY AND HELP

I’ve not had much experience with DTS packages before.I am using SQL Server 2000 and I have a table I wish to update.I have a spreadsheet with the updated records – this does not include all records and does not include all columns within the table,

I just wanted to know if it is still possible to update certain fields without having to include all the records and all the columns e.g.

Table 1

IDNAMESURNAME

1TEDSMITH

2FREDPERRY

3JOEYOUNG

Spreadsheet

IDSURNAME

2CASH

3WILLIS

Result

IDNAMESURNAME

1TEDSMITH

2FREDCASH

3JOEYOUNG

And the million-dollar question – please could you provide the steps to do this?

Take a look at the Data Driven Query Component|||

Can anyone provide any more information on this for me?

Thanks

|||If you need th enext level of help thn its probably best to move this thread to the SSIS forum|||

Look for "Building a Data Driven Query" in SQL Server 2000 Book Online, also found here: http://msdn2.microsoft.com/en-us/library/aa933507(sql.80).aspx

You'll want to follow the first example: "In the first example, every source row leads to the update of a destination row. Only one query type, an Update query, is used."

sqlsql

Monday, March 19, 2012

DTS Package Problem

Created a DTS Package is SQL that drops a table then recreates it then
imports data from an excel spreadsheet. This works fine if you run it
from the Local Packages and click execute package.
But, if you run it using the xp_cmdshell it doesn't popluate all the
columns. It will fill the 29 columns then the rest are null and then it
will fill the last 4 columns.
I thought that maybe that if the 30th column is null in the first row
then the rest would be null. So I sorted by that column in the package
and I'm getting the same results.
Does a package run differently with the xp_cmdshell versus righ
clicking and executing?
Thanks
MikeIf you run a exectue sql task with xp_cmdshell in it by right clicking and
executing, this will run same as executing full package with other steps.
How are you running it exactly (from where, how) and what is the sql stmt
inside xp_cmdshell ?
"Mike" wrote:

> Created a DTS Package is SQL that drops a table then recreates it then
> imports data from an excel spreadsheet. This works fine if you run it
> from the Local Packages and click execute package.
> But, if you run it using the xp_cmdshell it doesn't popluate all the
> columns. It will fill the 29 columns then the rest are null and then it
> will fill the last 4 columns.
> I thought that maybe that if the 30th column is null in the first row
> then the rest would be null. So I sorted by that column in the package
> and I'm getting the same results.
> Does a package run differently with the xp_cmdshell versus righ
> clicking and executing?
> Thanks
> Mike
>|||EXEC master..xp_cmdshell 'dtsrun /Sservername /E /NExcelInsert'
running this statement leaves most columns NULL.
Going through Enterprise manager --> local packages and right clicking
and hitting execute runs correctly.
MattB wrote:
> If you run a exectue sql task with xp_cmdshell in it by right clicking and
> executing, this will run same as executing full package with other steps.
> How are you running it exactly (from where, how) and what is the sql stmt
> inside xp_cmdshell ?
>
> "Mike" wrote:
>

Friday, March 9, 2012

DTS package

I have a DTS package which imports data from an Excel spreadsheet into an SQ
L
Server database. The package works fine, but I would like to take the
package to the next step in automation. How could I call the package(from V
B
.Net or QA) to be executed with only one change in the package: the name of
the excel spreadsheet and corresponding worksheet'
Thanks
ArcherSee
http://www.sqldts.com/default.aspx?292
for file manipulation.
You can call run the DTS Package from the command line with DTSrun.exe and
then pass a global variable to the package as a parameter with the /A
switch. (See dtsrun in Books Online) Alternatively, from VB or VB.Net, you
can instantiate a DTS Package object and run that. A DTSPackage has a
GlobalVariables collection that you can populate and an Execute method to
run it.(See "Executing DTS Packages with the DTS Object Model" in Books
Online for more details)
Jacco Schalkwijk
SQL Server MVP
"bagman3rd" <bagman3rd@.discussions.microsoft.com> wrote in message
news:FB2C9E14-2229-49CE-B464-16564F1FA557@.microsoft.com...
>I have a DTS package which imports data from an Excel spreadsheet into an
>SQL
> Server database. The package works fine, but I would like to take the
> package to the next step in automation. How could I call the package(from
> VB
> .Net or QA) to be executed with only one change in the package: the name
> of
> the excel spreadsheet and corresponding worksheet'
> Thanks
> Archer|||There's a couple ways you could do this...
Using parameters:
http://www.sqldts.com/default.aspx?234
DTS in VB.Net
http://www.sqldts.com/default.aspx?265
There's tons of DTS info on this site...
"bagman3rd" wrote:

> I have a DTS package which imports data from an Excel spreadsheet into an
SQL
> Server database. The package works fine, but I would like to take the
> package to the next step in automation. How could I call the package(from
VB
> .Net or QA) to be executed with only one change in the package: the name o
f
> the excel spreadsheet and corresponding worksheet'
> Thanks
> Archer|||here is some code from the microsoft site:
Dim dtsp As New DTS.Package
dtsp.LoadFromSQLServer( _
ServerName:="MyServer", _
ServerUserName:="MyUserID", _
ServerPassword:="MyPassword", _
PackageName:="DTSDemo")
dtsp.Execute()
Christy Warner
www.autoaudit.com
"Alien2_51" wrote:
> There's a couple ways you could do this...
> Using parameters:
> http://www.sqldts.com/default.aspx?234
> DTS in VB.Net
> http://www.sqldts.com/default.aspx?265
> There's tons of DTS info on this site...
>
> "bagman3rd" wrote:
>

Friday, February 24, 2012

DTS issue

In Microsoft SQL DTS I'm trying to run a package that convert output to a excel spreadsheet. Following error appears:
Error source: Microsoft Jet Database Engine
Error Description: Failure Creating File. What has added to my frustrations is, once I go to the server and open up the DTS package and click on destination it allows me to create new table, but that is only temporary. If I run a schedule job at a later time it fails again with the above message.Well if you're doing a CREATE, have you added the DROP?|||Brett, thanks for your reponse. It's only creating a dynamic table through DTS. When I take a look at the tables list it does not exist.|||Take a look at this post -> should answer your question.

http://www.dbforums.com/showthread.php?threadid=981661

kbk

Friday, February 17, 2012

dts import wizard

I want to import an excel spreadsheet 2000 into a sql server 2000 database.
When I import the columns from the excel spreadsheet, I am not always certai
n
what columns, and how many columns are included in each excel spreadsheet in
advance.
Thus is there a copy to automatically import all the columns from an excel
spreadsheet into a sql server 2000 database using the DTS import wizard? I
would like to be able to setup this copy metthod without having to declare
all the sql server 2000 columns in advance.
Thus, how would you do this?Hi
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\MyExcel.xls";
User ID=Admin;Password=;Extended properties=Excel 8.0')...Book1$
"wendy elizabeth 26th" <wendyelizabeth26th@.discussions.microsoft.com> wrote
in message news:E8BA9079-FAD3-4726-BBB6-557E7C8DC32C@.microsoft.com...
>I want to import an excel spreadsheet 2000 into a sql server 2000 database.
> When I import the columns from the excel spreadsheet, I am not always
> certain
> what columns, and how many columns are included in each excel spreadsheet
> in
> advance.
> Thus is there a copy to automatically import all the columns from an
> excel
> spreadsheet into a sql server 2000 database using the DTS import wizard? I
> would like to be able to setup this copy metthod without having to declare
> all the sql server 2000 columns in advance.
> Thus, how would you do this?

DTS import with dashes in source data

I'm trying to import numbers from an excel spreadsheet into a SQL table using a DTS package. I'm getting null values imported when my source data contains a dash (-). The data type for the source is text, and the datatype for the destinations is varchar(100). I've also tried a source data type of general. I'm doing a straight copy.

The source data might look 234-b87-456. Why would I be getting nulls when importing this data?

Thanks.
StumpedDid you check your transformation options and make sure that the columns line up correctly?|||I did. The column names in the source file are identical to the column names in the destinations table. I double-checked the mapping just to be sure all were correctly mapped.|||Try doing the same import but without the dashes in the columns.|||There are values within the same column that do not have dashes, and they import correctly. It is only the values with dashes that are not importing. All other values import correctly.

Thanks.

Tuesday, February 14, 2012

DTS import does not import all rows / records

Hi,

I am having trouble importing data from an excel spreadsheet into MS
SQL Server 2000 using DTS Wizard. The DTS import process is
successfull, no errors, but only 50 rows of approx. 1500 rows of data
are imported. I tried to remove 20 rows in the excel spreadsheet in
the interval row 0-50. When i later ran the import, only 30 rows were
imported. I deleted almost every row in the interval 0-50, with the
result of the import having 0 rows imported (but job ran
successfully). I decided to delete rows 0-100 in the spreadsheet in
order to see if the resolved the problem, but it didn't. As I
suspected something in the excel file to be the cause, I exported the
excel spreadsheeet to a tab delimited textfile, with only one row. A
DTS import resulted in importing approx 100 rows, double the amount of
the textfile, but the other 1400 rows were not imported. The data in
the column is containing numeric values only.

Please help me! What could possibly be the cause of DTS skipping rows
like that. DTS doesn't feel reliable at all :/

Regards,
BjrnYou may want to check your spreadsheet to see if it has a named range
and if that is what you are using in DTS. If the named range only
includes rows 1-50 then DTS will only import those rows.

I'm not sure what you were doing with the text file, since you said
that you exported one row and it imported 100.

HTH,
-Tom.|||Maybe it would be a better idea to avoid the DTS Wizard. Make a local
package on your server and you will have much more control over it.
And if an error occures, DTS will tell you what kind of error that is.

Elaksomfan wrote:
> Hi,
> I am having trouble importing data from an excel spreadsheet into MS
> SQL Server 2000 using DTS Wizard. The DTS import process is
> successfull, no errors, but only 50 rows of approx. 1500 rows of data
> are imported. I tried to remove 20 rows in the excel spreadsheet in
> the interval row 0-50. When i later ran the import, only 30 rows were
> imported. I deleted almost every row in the interval 0-50, with the
> result of the import having 0 rows imported (but job ran
> successfully). I decided to delete rows 0-100 in the spreadsheet in
> order to see if the resolved the problem, but it didn't. As I
> suspected something in the excel file to be the cause, I exported the
> excel spreadsheeet to a tab delimited textfile, with only one row. A
> DTS import resulted in importing approx 100 rows, double the amount of
> the textfile, but the other 1400 rows were not imported. The data in
> the column is containing numeric values only.
> Please help me! What could possibly be the cause of DTS skipping rows
> like that. DTS doesn't feel reliable at all :/
> Regards,
> Bjrn|||First save the excel sheet in csv format.
Then use DTS to import form the csv file.

Tawfiq.

Elaksomfan wrote:
> Hi,
> I am having trouble importing data from an excel spreadsheet into MS
> SQL Server 2000 using DTS Wizard. The DTS import process is
> successfull, no errors, but only 50 rows of approx. 1500 rows of data
> are imported. I tried to remove 20 rows in the excel spreadsheet in
> the interval row 0-50. When i later ran the import, only 30 rows were
> imported. I deleted almost every row in the interval 0-50, with the
> result of the import having 0 rows imported (but job ran
> successfully). I decided to delete rows 0-100 in the spreadsheet in
> order to see if the resolved the problem, but it didn't. As I
> suspected something in the excel file to be the cause, I exported the
> excel spreadsheeet to a tab delimited textfile, with only one row. A
> DTS import resulted in importing approx 100 rows, double the amount
of
> the textfile, but the other 1400 rows were not imported. The data in
> the column is containing numeric values only.
> Please help me! What could possibly be the cause of DTS skipping rows
> like that. DTS doesn't feel reliable at all :/
>
> Regards,
> Bjrn

DTS Help With Uploading An Excel Spreadsheet

Can somebody please tell me what I am doing wrong or need to do to resolve my issue. I having problems with one of the columns in an excel spreadsheet that I am trying to upload into the system. One of the columns contain values of both text and numbers such as 'ABC123', 'ABC124', '123456' etc. When I try uploading the sheet into SQL Server 2000 using DTS, the system removes all characters from the one column that I am having problems with. So entry 'ABC123' for example would be truncated to '123'. I tried formatting the column that I am having trouble with in excel to 'General' format as well as tried to transform the column to type varchar in SQL Server while using the DTS wizard but still had no luck. The problem is that SQL server thinks that the column is a float type column from the source and therefore truncates any characters.Well it seems that you are answering your own question.

The problem is that SQL server thinks that the column is a float type column from the source and therefore truncates any characters.

You will just need to play around with DTS and the import functionality of SQL to solve your issue. When you import into a new table using the import wizard be sure to go into the "transform" section and there you should be able to change the column type.

If this still fails trying creating the table structure first, this might force the spreadsheet data into the new column type.

Good luck,
Hope this helped|||I actually tried both steps and still cannot change the sources data type.