Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Wednesday, March 28, 2012

Importing txt files with sql server 2000

HI!

I am importing .txt files. How can i check the errors? I have created a
log file, but the problem is that i lose some characters.
I import for example:

Code
ABC
FZH
JHN

from a text file, but sometimes Code can be 4 caracters long
I import this 3 characters long now. When i add the same structured
text file with some rows lenght 4, it skips the last character, but i
get nothing in the log file.

please help
xgirlSo you already have a table after importing items with 3 characters,
and then later you import items with 4 characters?

Perhaps it set the field width to 3 based on what it found in the first
import.

Sounds like you may need to manually widen the field. Open the table
in design view and make sure the field width is large enough for 4
characters.|||If you are using a DTS for the import, you may want to check the
Transform Data Task. If you are using fixed width delimiting then that
may be the problem.|||I changed from varchar ->nvarchar if you mean that but still i get no
errors of lost characters.

The problem is i have a lot of .txt files and i will get in the future
the same files with different data. if i automaticlly import every
file, how can i be sure the data are not longer and i didn't lost some
characters.

thank you
xgirl|||I changed from varchar ->nvarchar if you mean that but still i get no
errors of lost characters.

The problem is i have a lot of .txt files and i will get in the future
the same files with different data. if i automaticlly import every
file, how can i be sure the data are not longer and i didn't lost some
characters.

thank you
xgirl

Wednesday, March 21, 2012

Importing Infopath Data

Hi
I'm relatively new to importing xml files into SQL. I have some infopath
files and I've tried the normal xml importing via sp_xml_preparedocument and
the other procs used for xml.
The xml can't be parsed becuase of an "invalid character".
I was wondering if my approach is correct ?
Thanks in advance.try this link:
http://support.microsoft.com/defaul...Q23883
3
regards,
Sarav...
"Mal .mullerjannie@.hotmail.com>" <<removethis> wrote in message
news:487FE266-C661-48B0-8B83-089AB4D96290@.microsoft.com...
> Hi
> I'm relatively new to importing xml files into SQL. I have some infopath
> files and I've tried the normal xml importing via sp_xml_preparedocument
> and
> the other procs used for xml.
> The xml can't be parsed becuase of an "invalid character".
> I was wondering if my approach is correct ?
> Thanks in advance.

Importing from Excel into Datbase tables

Hi
I have data in excel file which I wanted to import into sql tables, and I
wanted to do this programatically since I have to move the data first to
master table and then use the Master record key to insert into child table s
o
that i can have relationship data.
How can I do this with DTS?
Sample code will be much appreciated...
MakarandYou can use OpenRowset() to query data from excel like a *normal* table.
This should allow you to do insert/update/delete to your sql table.
select * from
OPENROWSET('Microsoft.Jet.OLED_B.4.0','Excel
8.0;Database=C:\Data\test.xls'_,Sheet1$)
--
-oj
"Makarand Keer" <MakarandKeer@.discussions.microsoft.com> wrote in message
news:8B4688A0-C5BE-48BC-A023-63284616DC7B@.microsoft.com...
> Hi
> I have data in excel file which I wanted to import into sql tables, and I
> wanted to do this programatically since I have to move the data first to
> master table and then use the Master record key to insert into child table
> so
> that i can have relationship data.
> How can I do this with DTS?
> Sample code will be much appreciated...
> Makarand|||Hi
This sounds like you want to load the data into a holding table and then use
queries to distribute it from there.
Loading into the holding table is just the same as any import from Excel,
you can use the import wizard to initially create the package or do it
manually.
To moving data from the holding table is probably best undertaken if you
wrote a stored procedure. In your backage you could as and "Execute SQL
Task" to execute the procedure. You can test the procedure out from query
analyser without having to call/step the package all the time. Using
statements such as INSERT...SELECT will allow you to choose which columns
from the holding table map onto the destination columns of the live tables.
Books online has example of the INSERT statement and information about DTS.
This site also has many examples http://www.sqldts.com/default.aspx?101
John
"Makarand Keer" <MakarandKeer@.discussions.microsoft.com> wrote in message
news:8B4688A0-C5BE-48BC-A023-63284616DC7B@.microsoft.com...
> Hi
> I have data in excel file which I wanted to import into sql tables, and I
> wanted to do this programatically since I have to move the data first to
> master table and then use the Master record key to insert into child table
> so
> that i can have relationship data.
> How can I do this with DTS?
> Sample code will be much appreciated...
> Makarand

Monday, March 12, 2012

Importing DATA wich are in SQL files

Hi
I have to install a lot of data wiich are initialized by an SQL file.
My problem is that the file is too big. My SQL requests exceeds 64Ko and
I cant start theses request in the SQL Editor of MS SQLSERVER 2K :-(
I would like import this file like in MySQL or Oracle, with a command
prompt or any tool.
How can I import this SQL File in SQLSERVER 2000 ?
Thanks in advance for your help.
Alexandre TouretAlexandre,
Did you try using OSQL utility?
AMB
"Alexandre Touret" wrote:

> Hi
> I have to install a lot of data wiich are initialized by an SQL file.
> My problem is that the file is too big. My SQL requests exceeds 64Ko and
> I cant start theses request in the SQL Editor of MS SQLSERVER 2K :-(
> I would like import this file like in MySQL or Oracle, with a command
> prompt or any tool.
> How can I import this SQL File in SQLSERVER 2000 ?
> Thanks in advance for your help.
> Alexandre Touret
>|||Hi
It there are SQL statements in a .SQL file, run them from the command line
by using the command line utility isql.exe
BOL has the syntax information for ISQL.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Alexandre Touret" <atouretNOSPAM@.free.fr> wrote in message
news:423aa143$0$29121$626a14ce@.news.free.fr...
> Hi
> I have to install a lot of data wiich are initialized by an SQL file.
> My problem is that the file is too big. My SQL requests exceeds 64Ko and
> I cant start theses request in the SQL Editor of MS SQLSERVER 2K :-(
> I would like import this file like in MySQL or Oracle, with a command
> prompt or any tool.
> How can I import this SQL File in SQLSERVER 2000 ?
> Thanks in advance for your help.
> Alexandre Touret

Friday, March 9, 2012

Importing data into SQL Server 2005 via ODBC

Hi

I've got an Ingres database of some 200 tables which I need to import
every night into SQL Server 2005 for use by Reporting Services. Most
of the tables will come across unchanged (a few need massaging to
handle time intervals correctly), but the Import Wizard only seems to
want to import one table (or more accurately query) at a time. I seem
to remember the old 2000 Import Wizard handled multiple tables - is
there any way of processing multiple tables in 2005, or must I resign
myself to writing 200 import packages in SSIS.

Chloe Crowder
The British LibraryChloe C (chloe@.mcrowdd.plus.com) writes:

Quote:

Originally Posted by

I've got an Ingres database of some 200 tables which I need to import
every night into SQL Server 2005 for use by Reporting Services. Most
of the tables will come across unchanged (a few need massaging to
handle time intervals correctly), but the Import Wizard only seems to
want to import one table (or more accurately query) at a time. I seem
to remember the old 2000 Import Wizard handled multiple tables - is
there any way of processing multiple tables in 2005, or must I resign
myself to writing 200 import packages in SSIS.


Are you looking at the Import Wizard in Mgmt Studio? I think you should
look into SQL Server Integration Services, for which you can create
packages in Business Intelligence Development Studio. (Although that is
as much I know about SSIS.)

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Hi Chloe,

Just had to do this today and it seems to work fine (although importing
multiple Excel sheets to multiple tables). After you select the Source and
Destination, there is a screen that asks to "Copy data from one or more
tables/views" or "Query" (not sure about the exact wording of the options
but something close). Then you can do mapping to destination tables/columns.
The last step is to execute or save as SSIS package.

If you do not see that option, check if you have the latest service pack. It
will be worth testing with SQL Server as Source, just to see if it has to do
with the driver for the source (I am confident you can import multiple
tables when the source is SQL Server).

HTH,

Plamen Ratchev
http://www.SQLStudio.com|||On Tue, 27 Nov 2007 19:13:10 -0500, "Plamen Ratchev"
<Plamen@.SQLStudio.comwrote:

Quote:

Originally Posted by

>Hi Chloe,
>
>Just had to do this today and it seems to work fine (although importing
>multiple Excel sheets to multiple tables). After you select the Source and
>Destination, there is a screen that asks to "Copy data from one or more
>tables/views" or "Query" (not sure about the exact wording of the options
>but something close). Then you can do mapping to destination tables/columns.
>The last step is to execute or save as SSIS package.
>
>If you do not see that option, check if you have the latest service pack. It
>will be worth testing with SQL Server as Source, just to see if it has to do
>with the driver for the source (I am confident you can import multiple
>tables when the source is SQL Server).
>
>HTH,
>
>Plamen Ratchev
>http://www.SQLStudio.com
>


Plamen

thanks for this. Importing multiple tables works well from SQL Server,
but with the Ingres server as the source the Copy data from one or
more tables/view option is greyed out, leaving only the option of a
single select statement in a query.

Ah well, I'll do it the hard way.

Chloe|||On Tue, 27 Nov 2007 22:59:18 +0000 (UTC), Erland Sommarskog
<esquel@.sommarskog.sewrote:

Quote:

Originally Posted by

>Chloe C (chloe@.mcrowdd.plus.com) writes:

Quote:

Originally Posted by

>I've got an Ingres database of some 200 tables which I need to import
>every night into SQL Server 2005 for use by Reporting Services. Most
>of the tables will come across unchanged (a few need massaging to
>handle time intervals correctly), but the Import Wizard only seems to
>want to import one table (or more accurately query) at a time. I seem
>to remember the old 2000 Import Wizard handled multiple tables - is
>there any way of processing multiple tables in 2005, or must I resign
>myself to writing 200 import packages in SSIS.


>
>Are you looking at the Import Wizard in Mgmt Studio? I think you should
>look into SQL Server Integration Services, for which you can create
>packages in Business Intelligence Development Studio. (Although that is
>as much I know about SSIS.)


Erland

I was rather hoping to, in effect, automate the creation of my SSIS
package with the Import Wizard, otherwise I need to do each import as
a separate task in SSIS.

Ah well, do it the hard way...

Chloe

Wednesday, March 7, 2012

Importing data from Excel

Hi
I'm having some data in some Excel spreadsheets, that I'd like to get into a
few tables in a SQL database.
What's the best/easiest way to do this with T-SQL?
I can do it with DTS, but I'd like to be able to do it with T-SQL so I'm
able to better control what's going to happen with the data.
I've tried to add my Excel sheet as a linked server, but then I simply can't
figure out how to select the columns in my sheet. (...apparently I don't
quite understand the explanation in BOL). It says that I have have to give a
range of cells a name, but maybe I have done this wrong. In Excel I've went
to Insert > Name and then added a name that points to the first column in my
sheet. When I then select the column, it then shows the name in the upper
left corner, so it actually seems ok.
When I then i QA runs a select statement "select * from
excelsource...filnavn" where excelsource is the "name" of my linked server,
I get the error message :
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider
did not give any information about the error.
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0'
IDBInitialize::Initialize returned 0x80004005: The provider did not give
any information about the error.].
This doesn't tells me a lot...
Can any of you guide to what I can check to make this work, or maybe give me
some other ideas of how to get data from Excel?
Thanks a lot...
Regards
SteenSteen
One option is to use OpenDataSource. Run this script on QA
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\MyExcel.xls";
User ID=Admin;Password=;Extended properties=Excel 8.0')...Book1$
"Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
news:%23WI%23WjRhEHA.3428@.TK2MSFTNGP11.phx.gbl...
> Hi
> I'm having some data in some Excel spreadsheets, that I'd like to get into
a
> few tables in a SQL database.
> What's the best/easiest way to do this with T-SQL?
> I can do it with DTS, but I'd like to be able to do it with T-SQL so I'm
> able to better control what's going to happen with the data.
> I've tried to add my Excel sheet as a linked server, but then I simply
can't
> figure out how to select the columns in my sheet. (...apparently I don't
> quite understand the explanation in BOL). It says that I have have to give
a
> range of cells a name, but maybe I have done this wrong. In Excel I've
went
> to Insert > Name and then added a name that points to the first column in
my
> sheet. When I then select the column, it then shows the name in the upper
> left corner, so it actually seems ok.
> When I then i QA runs a select statement "select * from
> excelsource...filnavn" where excelsource is the "name" of my linked
server,
> I get the error message :
> OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider
> did not give any information about the error.
> OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0'
> IDBInitialize::Initialize returned 0x80004005: The provider did not give
> any information about the error.].
> This doesn't tells me a lot...
> Can any of you guide to what I can check to make this work, or maybe give
me
> some other ideas of how to get data from Excel?
> Thanks a lot...
> Regards
> Steen
>
>|||Hi Uri
I think that I might be missing some basic knowledge about using these
features. I can't get it to work with OpenDataSource either. It gives me the
same error as before when using the LinkedServer option.
What I'm missing, is which userId and Password I have to supply? If I supply
anything else than "admin" as in your example, it gives me an
"authentication failed" error. That kind of indicates that it do get
authenticated with the admin userId, but that sounds a bit strange to me.
I'm also unsure about the last bit of the string -..Book1$? Is that
something I have to change to something else, or is it just the default
"sheet" (..I can't remember what it's called in english - I'm sitting with a
danish Excel - unfortunately).
I'm sorry if I sounds stupid with these questions, but I don't find BOL very
detailed on this subejct. If any of you have any links to other placed where
I can find some more detailed info about it, I'd be happy about that.
Regards
Steen
Uri Dimant wrote:[vbcol=seagreen]
> Steen
> One option is to use OpenDataSource. Run this script on QA
> SELECT *
> FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
> 'Data Source="c:\MyExcel.xls";
> User ID=Admin;Password=;Extended properties=Excel 8.0')...Book1$
>
> "Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
> news:%23WI%23WjRhEHA.3428@.TK2MSFTNGP11.phx.gbl...|||Import using DTS is the best and quick enough. Make your import into a work
table and then remake using SQL. So you'll have it under control.
Vlastik
"Steen Persson" <SPE@.REMOVEdatea.dk> pe v diskusnm pspvku
news:#WI#WjRhEHA.3428@.TK2MSFTNGP11.phx.gbl...
> Hi
> I'm having some data in some Excel spreadsheets, that I'd like to get into
a
> few tables in a SQL database.
> What's the best/easiest way to do this with T-SQL?
> I can do it with DTS, but I'd like to be able to do it with T-SQL so I'm
> able to better control what's going to happen with the data.
> I've tried to add my Excel sheet as a linked server, but then I simply
can't
> figure out how to select the columns in my sheet. (...apparently I don't
> quite understand the explanation in BOL). It says that I have have to give
a
> range of cells a name, but maybe I have done this wrong. In Excel I've
went
> to Insert > Name and then added a name that points to the first column in
my
> sheet. When I then select the column, it then shows the name in the upper
> left corner, so it actually seems ok.
> When I then i QA runs a select statement "select * from
> excelsource...filnavn" where excelsource is the "name" of my linked
server,
> I get the error message :
> OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider
> did not give any information about the error.
> OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0'
> IDBInitialize::Initialize returned 0x80004005: The provider did not give
> any information about the error.].
> This doesn't tells me a lot...
> Can any of you guide to what I can check to make this work, or maybe give
me
> some other ideas of how to get data from Excel?
> Thanks a lot...
> Regards
> Steen
>
>|||Your linked server may not function. drop it and try this:
EXEC sp_addlinkedserver 'ExcelSource',
'Jet 4.0',
'Microsoft.Jet.OLEDB.4.0',
'c:\test.xls',
NULL,
'Excel 5.0'
EXEC sp_addlinkedsrvlogin N'ExcelSource', false, sa, N'ADMIN', NULL
select * into #temp from ExcelSource...Sheet1$
select * from #temp
At least this works for me. HTH.
"Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
news:%23QdZMoShEHA.592@.TK2MSFTNGP11.phx.gbl...
> Hi Uri
> I think that I might be missing some basic knowledge about using these
> features. I can't get it to work with OpenDataSource either. It gives me
the
> same error as before when using the LinkedServer option.
> What I'm missing, is which userId and Password I have to supply? If I
supply
> anything else than "admin" as in your example, it gives me an
> "authentication failed" error. That kind of indicates that it do get
> authenticated with the admin userId, but that sounds a bit strange to me.
> I'm also unsure about the last bit of the string -..Book1$? Is that
> something I have to change to something else, or is it just the default
> "sheet" (..I can't remember what it's called in english - I'm sitting with
a
> danish Excel - unfortunately).
> I'm sorry if I sounds stupid with these questions, but I don't find BOL
very
> detailed on this subejct. If any of you have any links to other placed
where
> I can find some more detailed info about it, I'd be happy about that.
> Regards
> Steen
>
> Uri Dimant wrote:
>|||Hi
Thanks for your inputs... Now I've actually got it working with both
AddLinkedServer and OpenDataSource.
Whne using Richards example, it gave me an error accessing the Excel sheet.
That lead me to my error source which was the way I defined the path to my
Excel sheet. My mistake was that I thought the drive letters was what it was
on my workstation where I run QA, but it's what it is in the SQL
server...:-). I normally try avoiding using drive letters and using UNC
path's instead, but in this case I had the file on a drive where wasn't sure
about the UNC path...so much for trying the easy solution...:-).
As always...thanks a lot for your suggestions....
Regards
Steen
Richard Ding wrote:[vbcol=seagreen]
> Your linked server may not function. drop it and try this:
> EXEC sp_addlinkedserver 'ExcelSource',
> 'Jet 4.0',
> 'Microsoft.Jet.OLEDB.4.0',
> 'c:\test.xls',
> NULL,
> 'Excel 5.0'
> EXEC sp_addlinkedsrvlogin N'ExcelSource', false, sa, N'ADMIN', NULL
> select * into #temp from ExcelSource...Sheet1$
> select * from #temp
> At least this works for me. HTH.
>
> "Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
> news:%23QdZMoShEHA.592@.TK2MSFTNGP11.phx.gbl...

Sunday, February 19, 2012

importing a text file

Hi
I am trying to import a text file into sql server..but i am not able to do so..because the size of the var type is 8000..
and i have too many columns to change the variable manually
thus i copied the create table query from the import window
and i got an error
The table 'test' has been created but its maximum row size (25863) exceeds the maximum number of bytes per row (8060). INSERT or UPDATE of a row in this table will fail if the resulting row length exceeds 8060 bytes.

can some help
thanksDid you consider to use the memo data type TEXT instead VARCHAR?|||Is you column defined as char or is it defined as varchar?

A char column always requires the same amount of space, equivalent to its defined length.

A varchar column only requires as much space as the data it holds.

Are you trying to import an entire record into a single field? If you have a single field in your source data that is 8000+ characters, your only option is to split it or use a text or image datatype.

If you are still having problems, post your table definition and the sql you using to import the data.

blindman|||I don't think SQL would even allow you to create a table of the specified size with CHAR. Have you tried it yourself, bm?:cool:|||Thank you for all the response..
the solution to my problem..I edit the create table query during my import process and change the 8000 to 255 and then with that edited query i make an empty table and then i append my orginal text file with data into that empty table..
Well it is a long process..but it keeps going.
thanks for the help|||Are you saying that a maximum size of 255 is sufficient for you? If not, I repeat myself, consider to use TEXT instead of VARCHAR. It allows you to import texts of variable length without getting on the row length limits.|||The text and image type should not be used unless absolutely necessary. They require additional overhead, and have greatly limited functionality compared to char and varchar.

blindman|||I'd say, it's a pretty blunt statement. It invalidates the very presence of existence of companies that specialize in DMS (document management systems).|||Blunt yes, but not completely dull. Document Management is an area where the use of text and image data may be absolutely necessary.

blindman|||Document Management capabilities are present in many software products. Actually, those that are least reliable are the ones that avoid the usage of datatypes that are targeting this specific need, - to store large volumes of data. I've seen tricks like storing paths to actual document locations, or parsing text documents into 70-character lines. Cute, but if path is stored, - there is no guarantee for integrity of the referenced document, and in case of parsing - very resource-intensive in respect to drastic growth of such tables while loosing any formating information. Contrary to that, here we even store web pages in text fields and scan paper claims and store them into image. You also mentioned limited functionality? What do you mean? Each datatype should be treated accordingly, so if you attempt to treat text field using char/varchar approach, - sure, you loose functionality. But not because of "limited functionality" of the datatype... Wonder, because of what? ;)|||rdjabarov,

All the examples you mentioned are legitimate uses of text and image data.

As far as limited functionality, try indexing your text fields.
...or sorting them
...or using the LIKE operator
...or concatenating them

blindman|||bm: operations you mentioned are not designed for TEXT and IMAGE datatypes. But I like your way of looking at it:

- can you multiply a CHAR field?
- can you index a BIT field?
- can you store 2G of data into VARCHAR field?

Good luck answering :rolleyes:|||rdjabarov,

No. I use the appropriate datatype for the data. I recommend that you do the same. If you are using text and image columns in your design when you don't need to, then I pity the poor DBA who has to clean up after you when you get canned.

blindman|||By the way: what about a text-indexed table, or the powerful CONTAINS() function searching for words in a text field ?!

However, we shouldn't bother NosWal anymore. If anybody still has to say about the (ab)use of data types, I suggest to open a new thread.|||bm: you're REALLY on a mission. You just never answered what its name. What are you trying to say? It looks like you adore listening to yourself. I suggest call-forwarding services, until your office phone gets reassigned to your replacement. Then, - it'll be just this forum, until your internet connection gets cut due to late payments. Anything else you want to say please take it offline.|||rjabberon,

That makes five posts for you on this thread, and none of them have provided any assistance to noswal. Whatever mission I'm on, it ain't yours.|||that's a cute way of spelling my nick :)

But please don't count my posts, because your employer will fire you for your "math" :)