显示标签为“rows”的博文。显示所有博文
显示标签为“rows”的博文。显示所有博文

2012年3月26日星期一

Flat Files having Only Column Names in One file and the Rows in the other

Sorry if this question had already been answered previously. I was unable search the forum on this topic. How will I merge these and then configure the first row as Column names (As this helps to map to the destination column names automatically)

As far as I know, you can't. Why would you? A quick mapping exercise, name the columns etc, it not that much of a job...

You might do it by merging your files using a DOS command. Google merging text files in dos.|||

Hi Crispin,

Thanks for your reply

Unfortunately, We have hundreds of columns for each of the Flat File Sources among 20 in each Package. Naming them will obviously take ages.

Thanks

Subhash Subramanyam

|||I've had the same situation.

If you specify the file with the column names as the source, it'll do it for you. After that, you give it the files with the actual data in. Once columns are named, you do not need to do anything else with it. Unless the column order changes - in which case, you have a problem...

Otherwise, look at merging the files using DOS.

Another option you could try is to use Data Defractor for text files. Might be overkill for text but works non the less...

Flat File with random bad rows.

I have a text file that come from our client that is Column deliminated by ~ and row deliminated by {CR}{LF}.

There is a comment field that appearently is not cleaned up and has {CR}{LF} within the comment field.

I am new to SSIS and I'm wondering if there is a way to detect and correct the bad rows?

example file formet:

ORDERID~DATE~Comment~Address

1~2/3/2007~Some Comment~1234 oak st

2~2/3/2007~Some messed

up comment~345 oak st.

3~2/3/2007~Another comment~3214 asdf blvd.

Thank you.

You can use the Microsoft Visual Basic .NET RTrim function in a script run from the Script Component (configured as a transformation), to remove white space characters such as line feed and carriage return characters.

So the package data flow would include a Flat File Source connected to a Script Component. The output of the Script Component can then be sent to a destination or another transformation.

For information about the VB function, see "LTrim; RTrim; and Trim functions" at http://msdn2.microsoft.com/en-us/library/h9wz3dez(VS.71).aspx. For information about the Script Component, see "Extending the Data Flow with the Script Component" at http://msdn2.microsoft.com/en-us/library/ms136118.aspx.

|||If you do not want to mess with scripting you could use the REPLACE function in a Derived Column task and replace the space with another character.|||

How do you specify the line-feed character in the REPLACE function?

|||

Try

Code Snippet

\n

Generally, you use a \ character to escape special characters. \n indicates new line, \t indicates tab, etc.

|||

Thanks John, that works great

|||

If you enclose the escape character in quotes ("\n"), the expression will parse. For more information about using characters that require escape sequences in string literals, see "Literals (SSIS)" at http://msdn2.microsoft.com/en-us/library/ms141001.aspx.

Flat File with random bad rows.

I have a text file that come from our client that is Column deliminated by ~ and row deliminated by {CR}{LF}.

There is a comment field that appearently is not cleaned up and has {CR}{LF} within the comment field.

I am new to SSIS and I'm wondering if there is a way to detect and correct the bad rows?

example file formet:

ORDERID~DATE~Comment~Address

1~2/3/2007~Some Comment~1234 oak st

2~2/3/2007~Some messed

up comment~345 oak st.

3~2/3/2007~Another comment~3214 asdf blvd.

Thank you.

You can use the Microsoft Visual Basic .NET RTrim function in a script run from the Script Component (configured as a transformation), to remove white space characters such as line feed and carriage return characters.

So the package data flow would include a Flat File Source connected to a Script Component. The output of the Script Component can then be sent to a destination or another transformation.

For information about the VB function, see "LTrim; RTrim; and Trim functions" at http://msdn2.microsoft.com/en-us/library/h9wz3dez(VS.71).aspx. For information about the Script Component, see "Extending the Data Flow with the Script Component" at http://msdn2.microsoft.com/en-us/library/ms136118.aspx.

|||If you do not want to mess with scripting you could use the REPLACE function in a Derived Column task and replace the space with another character.

|||

How do you specify the line-feed character in the REPLACE function?

|||

Try

Code Snippet

\n

Generally, you use a \ character to escape special characters. \n indicates new line, \t indicates tab, etc.

|||

Thanks John, that works great

|||

If you enclose the escape character in quotes ("\n"), the expression will parse. For more information about using characters that require escape sequences in string literals, see "Literals (SSIS)" at http://msdn2.microsoft.com/en-us/library/ms141001.aspx.

Flat File with random bad rows.

I have a text file that come from our client that is Column deliminated by ~ and row deliminated by {CR}{LF}.

There is a comment field that appearently is not cleaned up and has {CR}{LF} within the comment field.

I am new to SSIS and I'm wondering if there is a way to detect and correct the bad rows?

example file formet:

ORDERID~DATE~Comment~Address

1~2/3/2007~Some Comment~1234 oak st

2~2/3/2007~Some messed

up comment~345 oak st.

3~2/3/2007~Another comment~3214 asdf blvd.

Thank you.

You can use the Microsoft Visual Basic .NET RTrim function in a script run from the Script Component (configured as a transformation), to remove white space characters such as line feed and carriage return characters.

So the package data flow would include a Flat File Source connected to a Script Component. The output of the Script Component can then be sent to a destination or another transformation.

For information about the VB function, see "LTrim; RTrim; and Trim functions" at http://msdn2.microsoft.com/en-us/library/h9wz3dez(VS.71).aspx. For information about the Script Component, see "Extending the Data Flow with the Script Component" at http://msdn2.microsoft.com/en-us/library/ms136118.aspx.

|||If you do not want to mess with scripting you could use the REPLACE function in a Derived Column task and replace the space with another character.|||

How do you specify the line-feed character in the REPLACE function?

|||

Try

Code Snippet

\n

Generally, you use a \ character to escape special characters. \n indicates new line, \t indicates tab, etc.

|||

Thanks John, that works great

|||

If you enclose the escape character in quotes ("\n"), the expression will parse. For more information about using characters that require escape sequences in string literals, see "Literals (SSIS)" at http://msdn2.microsoft.com/en-us/library/ms141001.aspx.

Flat file to table - rows out of order

Hi,

I noticed something strange today. I created a pkg that reads a flat file and writes the rows to a table.

In checking the data in the file against what's in the table, I noticed that the rows were inserted in a different order than they are in the file.

All the rows appear to be in the table correctly, but they're just not in the same order as in the file. I've never seen this before. But I checked very carefully, and this is indeed the case.

Is this normal?

Thanks

Is it normal? Well...its not not normal!

There is no concept of order in a database table. You should never assume that rows will get returned to you in the order that (you assume) they were inserted.

-Jamie

|||

That is not my understanding. For example, if you create a table, then insert a bunch of rows, one at a time, they will most definitely be returned in the order they were inserted. I have *never* seen an exception to this.

Perhaps the SSIS package is not inserting the rows in the order they are in the file?

Anyhow, I could be wrong, but this goes against my experience completely.

|||Not to sound mean or anything, but Jamie is absolutely right. There is no such thing as ordering in database land. Just because your experience "proves" otherwise, doesn't make it fact. The only way to guarantee order is to use an ORDER BY clause on your SQL statement which only controls the PRESENTATION of the data, not the way it's stored.

Do you have a situation that the records are out of order when ordering by an identity column, or are you merely using a "select * from table" statement without an ORDER BY clause?

This is perfectly normal behavior. You might want to add a sort transformation right before the destination. But still, there are no guarantees that the data will be stored "in order."|||By its definition, a database table is an unordered set of rows. While "most" of the time, a select without an ORDER BY clause will return the rows in the order they were entered, it is never guaranteed. The only way to guarantee retrieving rows in the order you want is with an ORDER BY clause on the query.|||

There are many factors that influence the order in which rows are returned. The most obvious being the presence of indexes.

Other possible causes may be the number of processors, what data is cached, datafile placement, datafile fill factors, hard drive configuration. There are a million and one things.

These same factors that affect the retrieval of data can also affect the insertion of data. Hopefully you can see how the order in which data is retrieved can be affected.

There is no concept of order in a database table. Period.

-Jamie

|||

Ok, ok - just had to make sure. As this goes against anything I have ever seen before. I've only been using SQL Server a couple years now, so there's a lot of things I haven't seen. This is one of them.

Anyways, thanks.

|||

sadie519590 wrote:

Ok, ok - just had to make sure. As this goes against anything I have ever seen before. I've only been using SQL Server a couple years now, so there's a lot of things I haven't seen. This is one of them.

Anyways, thanks.

No worries. All the training courses in the world wouldn't have taught you this. The only way you learn a product is by using it. I've been using this damn thing for seven years now and I only know a fraction of it

-Jamie

flat file to excel

hi,

i have a flat file with over 66,000 records. When I transfer it to excel (2003), it does not fit in due to limitation of rows. What can I do so that the remaining rows which will not fit in will go to another sheet. thanks a lot!

cherriesh

You can add a Conditional Split Transformation to route the data to multiple Excel destinations based on ranges of values in a specific column (i.e. ID). For more information about using the Conditional Split Transformation, see "Conditional Split Transformation" at http://msdn2.microsoft.com/en-us/library/ms137886.aspx.

|||

Take a look at this post for an example of how to create and output rows to multiple sheets:

http://rafael-salas.blogspot.com/2006/12/import-header-line-tables-_116683388696570741.html

Flat File Source, please Help !!

Hi all

I have some problems with the "Flat File Source" ...
I am trying to load a textfile, but IS allways cuts the rows ...
When I look at the preview while designing, the row is complete,
so I am wondering what IS is doing ...

Thanks for any comments

Best regards
Frank Uray

Here is what I am trying to load (one row from the file):
WPBX1 1.2 19330065002695435000 001200526000 000020002002-11-13-11.17.55.2220262006-03-03-05.50.44.322629002000010001AG2006-03-03-05.50.44.322629WIS030EPF033200602173410567000101 271275 2006030220060303200603032006030320060303 200603032006030320060303 200603032006030320060303200603031 0.000 200.000A UWCE 1 24617 10844890000000000 0.000000 0.000 0.000 0 149.500 149.500 149.500 00100010 0.000000000000000E+00 0.000000000000000E+00 0.000000000000000E+00 0.000000000000000E+00 1.000000000000000E+00 1.000000000000000E+00 0.000000000000000E+00 0.000000000000000E+0000 0000000001CV êê 00 1.150 200.000 0001-01-01-00.00.00.00000000120052600071200180K 712 71550 230.000 230.000 230.000 0.000 230.0000010 C 100.000000 2006-03-03-05.50.44.3226291567 230.000 230.000 230.000 0.000 230.0000010?C 100.000000 2006-03-03-05.50.44.3226291568 230.000 230.000 230.000 0.000 230.0000010?C 100.000000 2006-03-03-05.50.44.3226291585 230.000 230.000 230.000 0.000 230.0000010?C 100.000000 2006-03-03-05.50.44.3226291590 -80.500 -80.500 -80.500 0.000 -80.5000010?C 35.000000 2006-03-03-05.50.44.3226291640 -80.500 -80.500 -80.500 0.000 -80.5000010 C 35.000000 2006-03-03-05.50.44.3226291830 149.499 149.499 149.499 0.000 149.4990010?C 65.000000 2006-03-03-05.50.44.322629

On SQL Server I get only this:
WPBX1 1.2 19330065002695435000 001200526000 000020002002-11-13-11.17.55.2220262006-03-03-05.50.44.322629002000010001AG2006-03-03-05.50.44.322629WIS030EPF033200602173410567000101 271275 2006030220060303200603032006030320060303 200603032006030320060303 200603032006030320060303200603031 0.000 200.000A UWCE 1 24617 10844890000000000 0.000000 0.000 0.000 0 149.500 149.500 149.500 00100010 0.000000000000000E+00 0.000000000000000E+00 0.000000000000000E+00 0.000000000000000E+00 1.000000000000000E+00 1.000000000000000E+00 0.000000000000000E+00 0.000000000000000E+0000 0000000001CV

I can't be of much help here except to say check the data types in your flat file conenction manager. What are they set to?

-Jamie

|||

Hi Jamie

The DataType is set to: "string [DT_STR]"
I have also tried "text stream [DT_TEXT]"

IS seems not to be very consistently because why
is it correct on the Connection Managers Preview ?

Best regards
Frank Uray

|||Open the File connection manager and look at the advanced settings. Look at the output column width. By default the system sets it to 50. Increase this and it should work. Make sure this width matches the width on your field in the table.|||

Hi

Thanks for your comment!

I have checked this allready.

It has something to do with these characters ( êê) ...

Best regards
Frank Uray

|||

I think, if lenght is correct then ( )this might be set as a delimiter..

Chek in advanced properties

|||

Hi

The delimiter is set to "{CR}{LF}".
The problem is this character ( ), the question is how
can IS load such a row ?
As I told before, the preview in connection manager is correct.

Best regards
Frank Uray

|||

hi,

have a look at section fifty in the ProjectREAL docs, which may pertain to this situation.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/SQL05InSrREAL.asp

drew

sql

2012年3月22日星期四

Flat file import

I am trying to import a flat file with large rows into MS SQL Server. This flat file consists of about 100 columns of data, followed by a set of 10 columns repeated 50 times.

I would like very much to break the data apart in the import. What's the best way to handle it?

--
Dyolf KnipEither split up the file in two before the import, or, create an import table that consists of 100 columns, do the import, and work your way through the data finding out when the 10 column part starts. If you can select it, you can deal with it. It might work better or easier with a temp table with only one very wide column and do the processing after that.

Possibly there's a way to have one file and two fmt files that bcp uses to work on, inserting rows into two different tables. I'm not sure how to deal with the error's though.

Flat File Connection with different row types

I have a file format that uses many rows to describe relationships between one-to-many entries. Basically in many tables I one file with the only relations between tables been the order of the rows.

From what I’ve found so far, the Flat file Connection is not the correct Connection type to use for this. Is there something better suited, or documentation of creating Connection types.

Cheers Simeon.

This is script source component or custom source adapter territory. I recommend Don Farmer's book "Rational Guide To Scripting" which contains a step-by-step guide to building a script source component.

-Jamiesql

2012年3月21日星期三

Flat File Connection Manager does NOT fail

I use Flat File connection manager where I have defined the format of the file as "Ragged Right" (CR,LF Dos file) with no header rows. The columns are fixed width with Row Delimiter "{CR}{LF}".

The problem is when I process a file with incorrect format. The file execution does not throw an error. Instead it throws a warning " There is a partial row at the end of the file.".

How can I force the Flat file connection manager to FAIL if the format of the file is not matched exactly. I would think this would be the default behavior of Connection manager.

ie. If I have Connection manager setup for a dos file with 2 columns. Column 1 is 5 characters long, column 2 is 3 character long, and the end of line characters are CR, LF. However, if I send in file with 10 rows of 1 character and CR LF, the data flow works and processes these rows incorrectly. How can I force the task to fail if incoming file is not in defined format.

The "Ragged Right" format does not have any limitation on the size of the last column (delimited one), so if your file is missing some row delimiters the flat file parser will continue to look for them and probably swallow succeeding row(s).

You can restrict the size of your "ragged right" column by setting the OutputColumnWidth property of those columns on the Advanced page of the Flat File Connection Manager UI. That will make the flat file source fail if the truncation happens. If you would rather to redirect such rows, you can do that by setting "Redirect Row" for Truncation on the Error Output page of the Flat File Source UI, and then define your error flow.

HTH.|||Thanks. It worked.

Flag vs. Auxiliary Table

Hi, I want to accomplish the simple task of flagging a few rows (1-200) in a
large table (many rows i.e. 1,000,000+). I want to find these flagged rows
quickly. After some queries are run against these rows, the flag will be
changed to indicate "don't process these rows". If I use a bit or int or cha
r
flag, and create an index, I will have every row in the index, which seems a
waste of space (correct me if I'm wrong). If the flag is either a value or
null, will the null rows still be indexed? If not, this seems like an ideal
way to go. If so, it seems like it would be better to keep another table to
keep track of the rows needing processing temporarily. This aux table would
always contain only a few rows. So, this is really 2 questions;
1) Are null rows indexed? If not, then an index on a bit column (I
understand that these CAN be indexed in SS 2000), would be a vary small, ver
y
useful index for this problem. No?
2) I'm sure I'm not the only person in history to wonder about this
situation; it must be quite common (yes, I've done my googling but no satis.
answer); what is the OPTIMAL way to handle this situation? Perhaps it's
neither of my ideas and something else entirely.
Thanks!
ChrisI would create a second table, "Samplings" and keep the the keys of the
first batch of 200 rows in it, along with any other information about
the sample. The use of flags is too much like low level assembly
language progamming. Since you are dealing with a small set, anything
will run pretty fast for you.|||> Hi, I want to accomplish the simple task of flagging a few rows (1-200) in ad">
> large table (many rows i.e. 1,000,000+). I want to find these flagged rows
> quickly. After some queries are run against these rows, the flag will be
> changed to indicate "don't process these rows". If I use a bit or int or c
har
> flag, and create an index, I will have every row in the index, which seems
a
> waste of space (correct me if I'm wrong).
Every row will be represented in the index, but not with all columns in the
table. You will only
have the indexed column (which is very narrow) and also the bookmark (for SQ
L Server to find the
row). The bookmark is either 8 bytes for a heap table, or the clustering key
if it is a clustered
table.

> 1) Are null rows indexed?
Yes, the NULLs are included in the index. Seen the the index' perspective, a
NULL is just like any
other value.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"querylous" <querylous@.discussions.microsoft.com> wrote in message
news:4FD46302-C3C4-4290-A06F-B6F168C8A218@.microsoft.com...
> Hi, I want to accomplish the simple task of flagging a few rows (1-200) in
a
> large table (many rows i.e. 1,000,000+). I want to find these flagged rows
> quickly. After some queries are run against these rows, the flag will be
> changed to indicate "don't process these rows". If I use a bit or int or c
har
> flag, and create an index, I will have every row in the index, which seems
a
> waste of space (correct me if I'm wrong). If the flag is either a value or
> null, will the null rows still be indexed? If not, this seems like an idea
l
> way to go. If so, it seems like it would be better to keep another table t
o
> keep track of the rows needing processing temporarily. This aux table woul
d
> always contain only a few rows. So, this is really 2 questions;
> 1) Are null rows indexed? If not, then an index on a bit column (I
> understand that these CAN be indexed in SS 2000), would be a vary small, v
ery
> useful index for this problem. No?
> 2) I'm sure I'm not the only person in history to wonder about this
> situation; it must be quite common (yes, I've done my googling but no sati
s.
> answer); what is the OPTIMAL way to handle this situation? Perhaps it's
> neither of my ideas and something else entirely.
> Thanks!
> Chris|||Another option would be to create an indexed view for each flag state - if
for some reason you couldn't use an auxilary table, and/or you'd experience
poor performance due to low selectiveness of the index.
ML
http://milambda.blogspot.com/|||Thanks all. Since null rows ARE indexed, wouldn't all those nulls with just
a
few non nulls slow down the search of the index? I'm not exactly sure how th
e
search would run, but if it's b-tree, won't the search have to keep branchin
g
and branching and branching until it finds what it's looking for? Or does it
have some way of knowing "ok, all the actual values [non nulls] are right
here at the top of the index"'
"Tibor Karaszi" wrote:

> Every row will be represented in the index, but not with all columns in th
e table. You will only
> have the indexed column (which is very narrow) and also the bookmark (for
SQL Server to find the
> row). The bookmark is either 8 bytes for a heap table, or the clustering k
ey if it is a clustered
> table.
>
> Yes, the NULLs are included in the index. Seen the the index' perspective,
a NULL is just like any
> other value.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "querylous" <querylous@.discussions.microsoft.com> wrote in message
> news:4FD46302-C3C4-4290-A06F-B6F168C8A218@.microsoft.com...
>|||The null rows will make the index larger on disk, but they should
not slow things down. An index on thisCol, if used in a
query containing (thisCol is not null), will quickly s from
the root of the index directly down to the first non-null thisCol
value in the leaf level, then scan across the leaves with non-null
thisCol values.
Although it doesn't actually matter here, duplicate
index keys appear only once at levels above the leaf level of
the index. In no case will there be branching and branching
and looking until it finds what it wants. The initial s to the
first index row retrieved is effectively a b-tree search within
only the unique values of the indexed columns. Since you
have very few unique values, the non-leaf part of your
index is very small.
Suppose you have 12 offices in a very large building. In
the lobby (the root of the index), there's a sign that says:
ChrisCom: Rooms 8230-8254
Microsoft: Rooms 101-8229
You don't blindly start in the middle of the building and
hop around looking at actual offices to find out where
to go (as you would if you were doing a binary search
on an ordered collection).
If there are a lot of distinct companies in the building,
you might see this, which is only a little more trouble:
AbbottCom - CanadaCom: See detailed directory at left.
CenterCom - LakshmiCom: See detailed directory on page below
MaryCom - ZsoltCom: See detailed directory at right.
Only distinct keys need to be in the upper levels of the index.
Steve Kass
Drew University
querylous wrote:
>Thanks all. Since null rows ARE indexed, wouldn't all those nulls with just
a
>few non nulls slow down the search of the index? I'm not exactly sure how t
he
>search would run, but if it's b-tree, won't the search have to keep branchi
ng
>and branching and branching until it finds what it's looking for? Or does i
t
>have some way of knowing "ok, all the actual values [non nulls] are right
>here at the top of the index"'
>"Tibor Karaszi" wrote:
>
>|||Well, it sort of depends on what you're doing, and what the flag means.
For example, I once had a client that decided that they wanted to
basically archive all of the data that they'd ever used in their
database. (For some compliance reasons.) The solution that they chose
was to give each row a BIT field called ActiveFL (I can hear CELKO
scream right now!), and then basically append it to each query like so:
SELECT * FROM Person
WHERE Name LIKE 'Joe'
AND ActiveFL = 1
So pretty much every query in the system had "AND ActiveFL = 1" appended
to the end. What made matters much worse was that these were rows that
didn't stay "active" for a long time - they basically got inactivated
after a short period of time. So as time went by, you might have, say,
1 million inactive rows and a thousand active rows. Well, what's the
problem with this?
1) You have to remember to add "AND ActiveFL = 1" to all of your queries
in order to not pick up false data. Not toooo bad, I guess you could
use a view for this...
2) Here's the real killer -- You can't effectively index the tables.
Say you have an index on "Name" in my example. If you know that you're
never going to search for the inactive records by name, tough luck,
you're still indexing on the word "Name" for the million inactive rows
that you don't care about. This isn't an efficient indexing scheme, and
as you can imagine, the index overhead just grows over time like this.
3) Even if you were going to index on ActiveFL (as a single column), you
might be in trouble. It's not a selective index, and will probably be
ignored by the optimizer, depending on what the proportion of active to
inactive rows are. The only thing you could possibly do is add ActiveFL
to each index on the table, which will increase your index size and only
compound issue 2.
IMO, In situations like these, where you really don't want to consider
the rows anymore, deleting the inactive rows and moving them to another
"historical" or "archive" table can have a lot of benefits from the
standpoint of performance and manageability.
-Dave
querylous wrote:
> Hi, I want to accomplish the simple task of flagging a few rows (1-200) in
a
> large table (many rows i.e. 1,000,000+). I want to find these flagged rows
> quickly. After some queries are run against these rows, the flag will be
> changed to indicate "don't process these rows". If I use a bit or int or c
har
> flag, and create an index, I will have every row in the index, which seems
a
> waste of space (correct me if I'm wrong). If the flag is either a value or
> null, will the null rows still be indexed? If not, this seems like an idea
l
> way to go. If so, it seems like it would be better to keep another table t
o
> keep track of the rows needing processing temporarily. This aux table woul
d
> always contain only a few rows. So, this is really 2 questions;
> 1) Are null rows indexed? If not, then an index on a bit column (I
> understand that these CAN be indexed in SS 2000), would be a vary small, v
ery
> useful index for this problem. No?
> 2) I'm sure I'm not the only person in history to wonder about this
> situation; it must be quite common (yes, I've done my googling but no sati
s.
> answer); what is the OPTIMAL way to handle this situation? Perhaps it's
> neither of my ideas and something else entirely.
> Thanks!
> Chris|||querylous (querylous@.discussions.microsoft.com) writes:
> Hi, I want to accomplish the simple task of flagging a few rows (1-200)
> in a large table (many rows i.e. 1,000,000+). I want to find these
> flagged rows quickly. After some queries are run against these rows, the
> flag will be changed to indicate "don't process these rows". If I use a
> bit or int or char flag, and create an index, I will have every row in
> the index, which seems a waste of space (correct me if I'm wrong). If
> the flag is either a value or null, will the null rows still be indexed?
> If not, this seems like an ideal way to go. If so, it seems like it
> would be better to keep another table to keep track of the rows needing
> processing temporarily. This aux table would always contain only a few
> rows. So, this is really 2 questions;
In addition to the other posts:
o Indexing on a bit column in a case like yours is likely to be
successful, as the index will be very selective for finding flagged
rows.
o Assuming that your flag is a bit column, there is a gotcha. Don't say:
SELECT ... FROM tbl WHERE flag = 1
but say:
SELECT ... FRPM tbl WHERE flag = convert(bit, 1)
This is because of the rules for data-type conversions in SQL. The
literal 1 is an integer, so the flag will be implicitly converted to
bit. But once the column is involved in a operation, the index
can no longer be sed, only scanned, which of course is less
effecient.
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|||Steve thanks for this great explanation, it really answers a lot of question
s
I've always had about indexing. So, I think it's fine to create an index on
a
flag column for this table; also fine to create an aux table; I think I'll
try a flag first and see how it goes.
Chris|||Hi Dave, good points; the table on which I'll have the flag contains a lot o
f
data which is used very actively throughout the system. It's a table
containing scheduling info, and relates to many other tables and joins in th
e
system used all the time. But, the flag isn't used to determine which record
s
are active or inactive; it's used to determine if a template has been
generated (a process totally outside the db; ie. we run a script that
generates templates for another application; it queries the db for all rows
we haven't generated a template for, and generates one for each row not
already done. Then it marks those rows as done). Even when rows are marked
"needsTemplate = 0", we'll still be accessing those rows all the time for
other purposes. Ultimately, since it is a schedule, many rows will become
archival; at that point, we will move them to a warehouse table.
So, this is the challenge; based on what I've learned here, I think it's ok
to go with such a flag, or, definitely ok to use an aux table.
Thanks for your input!
Chris
"Dave Markle" <"dma[remove_ZZ]ZZrkle" wrote:

> Well, it sort of depends on what you're doing, and what the flag means.
> For example, I once had a client that decided that they wanted to
> basically archive all of the data that they'd ever used in their
> database. (For some compliance reasons.) The solution that they chose
> was to give each row a BIT field called ActiveFL (I can hear CELKO
> scream right now!), and then basically append it to each query like so:
> SELECT * FROM Person
> WHERE Name LIKE 'Joe'
> AND ActiveFL = 1
> So pretty much every query in the system had "AND ActiveFL = 1" appended
> to the end. What made matters much worse was that these were rows that
> didn't stay "active" for a long time - they basically got inactivated
> after a short period of time. So as time went by, you might have, say,
> 1 million inactive rows and a thousand active rows. Well, what's the
> problem with this?
> 1) You have to remember to add "AND ActiveFL = 1" to all of your queries
> in order to not pick up false data. Not toooo bad, I guess you could
> use a view for this...
> 2) Here's the real killer -- You can't effectively index the tables.
> Say you have an index on "Name" in my example. If you know that you're
> never going to search for the inactive records by name, tough luck,
> you're still indexing on the word "Name" for the million inactive rows
> that you don't care about. This isn't an efficient indexing scheme, and
> as you can imagine, the index overhead just grows over time like this.
> 3) Even if you were going to index on ActiveFL (as a single column), you
> might be in trouble. It's not a selective index, and will probably be
> ignored by the optimizer, depending on what the proportion of active to
> inactive rows are. The only thing you could possibly do is add ActiveFL
> to each index on the table, which will increase your index size and only
> compound issue 2.
> IMO, In situations like these, where you really don't want to consider
> the rows anymore, deleting the inactive rows and moving them to another
> "historical" or "archive" table can have a lot of benefits from the
> standpoint of performance and manageability.
> -Dave
> querylous wrote:
>

2012年3月19日星期一

Fixed width output problem

I'm sending the results of an SSIS data flow to an fixed-width flat file output, but instead of getting separate rows of data, like so:

row1data...
row2data...
row3data...
etc...

I get:

row1data...row2data...row3data...etc...

Is there some setting I'm missing in either the flat file output or the file connection to turn this on?

The fixed width format does not include the row delimiters.

You can use the Ragged right format if your last column always has a fixed format or you do not care for it to be fixed.

If you do have a requirement for the fixed length of the last column (like you always want integer values to take 10 characters in the file), you can create your Flat File Connection manager by clicking "New..." on the Flat File Destination UI and choose the "Fixed width with row delimiters" option. That will actually create the ragged right file with a dummy row delimiter column.

HTH.

|||Thank you. That's what I needed.|||Thanks so much for this. I wanted SSIS to mimic the fixed width behavior of DTS or SQL Server 2000 export wizard. This was exactly what I was looking for.

2012年3月11日星期日

Fixed Table Size

I have a report with several tables inside and I would like to fix the
size of the tables regarding the number of detail rows and appear a
scroll bar to show the rest of the table and therefore having acess
to all table in one page. Is it possible? I'm using SRS 2000.
Thanks,
Pedro GeraldesOne suggestion is that you can use subreport to get the required functionality.
Amarnath
"pedro.geraldes@.netvisao.pt" wrote:
> I have a report with several tables inside and I would like to fix the
> size of the tables regarding the number of detail rows and appear a
> scroll bar to show the rest of the table and therefore having acess
> to all table in one page. Is it possible? I'm using SRS 2000.
> Thanks,
> Pedro Geraldes
>|||On Feb 4, 2:09 pm, Amarnath <Amarn...@.discussions.microsoft.com>
wrote:
> One suggestion is that you can use subreport to get the required functionality.
> Amarnath
>
I create the Subreport but it still show all information. How can I
limit the Display Area size of the Subreport?
>
> "pedro.geral...@.netvisao.pt" wrote:
> > I have a report with several tables inside and I would like to fix the
> > size of the tables regarding the number of detail rows and appear a
> > scroll bar to show the rest of the table and therefore having acess
> > to all table in one page. Is it possible? I'm using SRS 2000.
> > Thanks,
> > Pedro Geraldes- Hide quoted text -
> - Show quoted text -|||When you place a subreport from the toolbox, you need to expand the subreport
rectangle to fit into your page and the hori/verti scroll automatically comes
to your page depending up on the length of the report inside a subreport
Amarnath
"pedro.geraldes@.netvisao.pt" wrote:
> On Feb 4, 2:09 pm, Amarnath <Amarn...@.discussions.microsoft.com>
> wrote:
> > One suggestion is that you can use subreport to get the required functionality.
> >
> > Amarnath
> >
> I create the Subreport but it still show all information. How can I
> limit the Display Area size of the Subreport?
> >
> >
> > "pedro.geral...@.netvisao.pt" wrote:
> > > I have a report with several tables inside and I would like to fix the
> > > size of the tables regarding the number of detail rows and appear a
> > > scroll bar to show the rest of the table and therefore having acess
> > > to all table in one page. Is it possible? I'm using SRS 2000.
> >
> > > Thanks,
> >
> > > Pedro Geraldes- Hide quoted text -
> >
> > - Show quoted text -
>
>|||Are you working on SRS 2000? Because when I run the report the
subreport grows to show full information, that is more that the size
that I define for the subreport.|||currently I am on 2005 and I have worked on 2000 as well, very much. See that
you remove most of the spaces from the report which you are refering in your
subreport, ofcourse you cant make it very small subreport area and refer a
big report. Try different sizes..
Amarnath
"pedro.geraldes@.netvisao.pt" wrote:
> Are you working on SRS 2000? Because when I run the report the
> subreport grows to show full information, that is more that the size
> that I define for the subreport.
>

fixed page size

I have a page body and a page footer in my report. The page body has a table in its data region. It seems, based on the number of rows displayed, the footer section is adjusting itself tobe shown next to thelast row of the table. That is, if I want to show 15 records in a 2 page report, then in the first page there are 10 records and the footer appears after the 10 the record. But in the 2nd page, the footer is appearing immediately after the 5 record, the footer is appearing. the footer moves itself up to do so.
Question: Do do i make sure that the footer appears at the same place in all the reports irrespective of the data shown in the page body.
Thankx in advance.
Rajesh Jagadeesan.
--
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.For print-oriented output formats (such as image and PDF), you'll get the
footer in the same place on each page.
For online-oriented output formats (such as HTML), the footer appears
immediately after the last item on the logical page, so as not to leave a
useless blank space (which would force the user to scroll unnecessarily).
--
This post is provided 'AS IS' with no warranties, and confers no rights. All
rights reserved. Some assembly required. Batteries not included. Your
mileage may vary. Objects in mirror may be closer than they appear. No user
serviceable parts inside. Opening cover voids warranty. Keep out of reach of
children under 3.
"SqlJunkies User" <User@.-NOSPAM-SqlJunkies.com> wrote in message
news:ukkjfTvcEHA.2520@.TK2MSFTNGP12.phx.gbl...
> I have a page body and a page footer in my report. The page body has a
table in its data region. It seems, based on the number of rows displayed,
the footer section is adjusting itself tobe shown next to thelast row of the
table. That is, if I want to show 15 records in a 2 page report, then in
the first page there are 10 records and the footer appears after the 10 the
record. But in the 2nd page, the footer is appearing immediately after the
5 record, the footer is appearing. the footer moves itself up to do so.
> Question: Do do i make sure that the footer appears at the same place in
all the reports irrespective of the data shown in the page body.
> Thankx in advance.
> Rajesh Jagadeesan.
> --
> Posted using Wimdows.net NntpNews Component -
> Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.

2012年3月7日星期三

First, Last, Middle ??

I have a Matrix that always displays two rows of data.
One row show values from Jan 1 of the current year.
The second row shows values for today.
In the foot I show the % the values have changed so YTD with the following
formula:
=(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
First(Fields!Core.Value) * 100
This works great and looks like this:
Date | Core
--
Jan 1 2005 | $400
Aug 31 2005 | $500
--
Footer +25%
I have been asked to add in the value from a year ago today but still
display the change in value from just Jan 1.
Date | Core
--
Aug 31 2004 | $300
Jan 1 2005 | $400
Aug 31 2005 | $500
--
Footer +25% (Diff between Jan 1 and Aug 31 2005)
How would I calc the % change in the footer. My formula will not work as the
"First" value is a year ago today not Jan 1. Is there a "Middle" function ?
:) :)
Thoughts ?
Thanks in Advance
Pete MitchellTry something like this:
=(Last(Fields!Core.Value) - CDate("1/1/"&CStr(Year(First(Fields!Core.Value)))))
/
CDate("1/1/"&CStr(Year(First(Fields!Core.Value)))) * 100
GeoSynch
"PeteMitchell" <PeteMitchell@.discussions.microsoft.com> wrote in message
news:EE7A94F6-8F3B-46EC-87E3-7DA323C927D0@.microsoft.com...
>I have a Matrix that always displays two rows of data.
> One row show values from Jan 1 of the current year.
> The second row shows values for today.
> In the foot I show the % the values have changed so YTD with the following
> formula:
> =(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
> First(Fields!Core.Value) * 100
> This works great and looks like this:
> Date | Core
> --
> Jan 1 2005 | $400
> Aug 31 2005 | $500
> --
> Footer +25%
> I have been asked to add in the value from a year ago today but still
> display the change in value from just Jan 1.
> Date | Core
> --
> Aug 31 2004 | $300
> Jan 1 2005 | $400
> Aug 31 2005 | $500
> --
> Footer +25% (Diff between Jan 1 and Aug 31 2005)
> How would I calc the % change in the footer. My formula will not work as the
> "First" value is a year ago today not Jan 1. Is there a "Middle" function ?
> :) :)
> Thoughts ?
> Thanks in Advance
> Pete Mitchell|||Actually, it probably shoud be:
=(Last(Fields!Core.Value) - CDate("1/1/"&CStr(Year(Last(Fields!Core.Value)))))
/ CDate("1/1/"&CStr(Year(Last(Fields!Core.Value)))) * 100
GeoSynch
"GeoSynch" <SpamSlayed@.Casablanca.com> wrote in message
news:ecLK3yprFHA.3884@.TK2MSFTNGP11.phx.gbl...
> Try something like this:
> =(Last(Fields!Core.Value) -
> CDate("1/1/"&CStr(Year(First(Fields!Core.Value))))) /
> CDate("1/1/"&CStr(Year(First(Fields!Core.Value)))) * 100
>
> GeoSynch
>
> "PeteMitchell" <PeteMitchell@.discussions.microsoft.com> wrote in message
> news:EE7A94F6-8F3B-46EC-87E3-7DA323C927D0@.microsoft.com...
>>I have a Matrix that always displays two rows of data.
>> One row show values from Jan 1 of the current year.
>> The second row shows values for today.
>> In the foot I show the % the values have changed so YTD with the following
>> formula:
>> =(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
>> First(Fields!Core.Value) * 100
>> This works great and looks like this:
>> Date | Core
>> --
>> Jan 1 2005 | $400
>> Aug 31 2005 | $500
>> --
>> Footer +25%
>> I have been asked to add in the value from a year ago today but still
>> display the change in value from just Jan 1.
>> Date | Core
>> --
>> Aug 31 2004 | $300
>> Jan 1 2005 | $400
>> Aug 31 2005 | $500
>> --
>> Footer +25% (Diff between Jan 1 and Aug 31 2005)
>> How would I calc the % change in the footer. My formula will not work as the
>> "First" value is a year ago today not Jan 1. Is there a "Middle" function ?
>> :) :)
>> Thoughts ?
>> Thanks in Advance
>> Pete Mitchell
>|||Thanks a bunch.
How does that work ?
There are two fields in play here : Date and Core
How is that get the Core.value when the Date.value = Jan 1 2005 ?
Pete
"GeoSynch" wrote:
> Actually, it probably shoud be:
> =(Last(Fields!Core.Value) - CDate("1/1/"&CStr(Year(Last(Fields!Core.Value)))))
> / CDate("1/1/"&CStr(Year(Last(Fields!Core.Value)))) * 100
>
> GeoSynch
>
> "GeoSynch" <SpamSlayed@.Casablanca.com> wrote in message
> news:ecLK3yprFHA.3884@.TK2MSFTNGP11.phx.gbl...
> > Try something like this:
> > =(Last(Fields!Core.Value) -
> > CDate("1/1/"&CStr(Year(First(Fields!Core.Value))))) /
> > CDate("1/1/"&CStr(Year(First(Fields!Core.Value)))) * 100
> >
> >
> > GeoSynch
> >
> >
> > "PeteMitchell" <PeteMitchell@.discussions.microsoft.com> wrote in message
> > news:EE7A94F6-8F3B-46EC-87E3-7DA323C927D0@.microsoft.com...
> >>I have a Matrix that always displays two rows of data.
> >> One row show values from Jan 1 of the current year.
> >> The second row shows values for today.
> >>
> >> In the foot I show the % the values have changed so YTD with the following
> >> formula:
> >>
> >> =(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
> >> First(Fields!Core.Value) * 100
> >>
> >> This works great and looks like this:
> >> Date | Core
> >> --
> >> Jan 1 2005 | $400
> >> Aug 31 2005 | $500
> >> --
> >> Footer +25%
> >>
> >> I have been asked to add in the value from a year ago today but still
> >> display the change in value from just Jan 1.
> >>
> >> Date | Core
> >> --
> >> Aug 31 2004 | $300
> >> Jan 1 2005 | $400
> >> Aug 31 2005 | $500
> >> --
> >> Footer +25% (Diff between Jan 1 and Aug 31 2005)
> >>
> >> How would I calc the % change in the footer. My formula will not work as the
> >> "First" value is a year ago today not Jan 1. Is there a "Middle" function ?
> >> :) :)
> >>
> >> Thoughts ?
> >>
> >> Thanks in Advance
> >>
> >> Pete Mitchell
> >
> >
>
>|||CDate("1/1/"&CStr(Year(Last(Fields!Core.Value)))) evaluates thusly:
Last(Fields!Core.Value) = '08/31/2005' data type Date
Year(Last(Fields!Core.Value)) = '2005' data type Integer
CStr(Year(Last(Fields!Core.Value))) converts it to a string value
so that when concatenated with "1/1/" it will evaluate to string value
"1/1/2005"
CDate converts it back to an actual date value of '01/01/2005'
GeoSynch
"PeteMitchell" <PeteMitchell@.discussions.microsoft.com> wrote in message
news:940A01C6-D8A5-4C44-8BA4-3AF232AD790F@.microsoft.com...
> Thanks a bunch.
> How does that work ?
> There are two fields in play here : Date and Core
> How is that get the Core.value when the Date.value = Jan 1 2005 ?
> Pete
>
> "GeoSynch" wrote:
>> Actually, it probably shoud be:
>> =(Last(Fields!Core.Value) -
>> CDate("1/1/"&CStr(Year(Last(Fields!Core.Value)))))
>> / CDate("1/1/"&CStr(Year(Last(Fields!Core.Value)))) * 100
>>
>> GeoSynch
>>
>> "GeoSynch" <SpamSlayed@.Casablanca.com> wrote in message
>> news:ecLK3yprFHA.3884@.TK2MSFTNGP11.phx.gbl...
>> > Try something like this:
>> > =(Last(Fields!Core.Value) -
>> > CDate("1/1/"&CStr(Year(First(Fields!Core.Value))))) /
>> > CDate("1/1/"&CStr(Year(First(Fields!Core.Value)))) * 100
>> >
>> >
>> > GeoSynch
>> >
>> >
>> > "PeteMitchell" <PeteMitchell@.discussions.microsoft.com> wrote in message
>> > news:EE7A94F6-8F3B-46EC-87E3-7DA323C927D0@.microsoft.com...
>> >>I have a Matrix that always displays two rows of data.
>> >> One row show values from Jan 1 of the current year.
>> >> The second row shows values for today.
>> >>
>> >> In the foot I show the % the values have changed so YTD with the following
>> >> formula:
>> >>
>> >> =(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
>> >> First(Fields!Core.Value) * 100
>> >>
>> >> This works great and looks like this:
>> >> Date | Core
>> >> --
>> >> Jan 1 2005 | $400
>> >> Aug 31 2005 | $500
>> >> --
>> >> Footer +25%
>> >>
>> >> I have been asked to add in the value from a year ago today but still
>> >> display the change in value from just Jan 1.
>> >>
>> >> Date | Core
>> >> --
>> >> Aug 31 2004 | $300
>> >> Jan 1 2005 | $400
>> >> Aug 31 2005 | $500
>> >> --
>> >> Footer +25% (Diff between Jan 1 and Aug 31 2005)
>> >>
>> >> How would I calc the % change in the footer. My formula will not work as
>> >> the
>> >> "First" value is a year ago today not Jan 1. Is there a "Middle" function
>> >> ?
>> >> :) :)
>> >>
>> >> Thoughts ?
>> >>
>> >> Thanks in Advance
>> >>
>> >> Pete Mitchell
>> >
>> >
>>

First, Last, Again

I have a Matrix that always displays two rows of data.
One row show values from Jan 1 of the current year.
The second row shows values for today.
In the foot I show the % the values have changed so YTD with the following
formula:
=(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
First(Fields!Core.Value) * 100
This works great and looks like this:
Date | Core
--
Jan 1 2005 | $400
Aug 31 2005 | $500
--
Footer +25%
I have been asked to add in the value from a year ago today but still
display the change in value from just Jan 1.
Date | Core
--
Aug 31 2004 | $300
Jan 1 2005 | $400
Aug 31 2005 | $500
--
Footer +25% (Diff between Jan 1 and Aug 31 2005)
How would I calc the % change in the footer. My formula will not work as the
"First" value is a year ago today not Jan 1. Is there a "Middle" function ?
:) :)
Thoughts ?
Thanks in Advance
Pete Mitchellmaybe you could use groups to accomplish the division of the first row from
the other two. Then you could just hide the group header and footer of
group1 and hide the header of group 2. I am not sure how the first and last
will work with groups ... just a thought
> Date | Core
> --
> Aug 31 2004 | $300 ======== > group 1
> Jan 1 2005 | $400 ========> group 2
> Aug 31 2005 | $500 ========> group 2
> --
> Footer +25% (Diff between Jan 1 and Aug 31 2005)
"PeteMitchell" wrote:
> I have a Matrix that always displays two rows of data.
> One row show values from Jan 1 of the current year.
> The second row shows values for today.
> In the foot I show the % the values have changed so YTD with the following
> formula:
> =(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
> First(Fields!Core.Value) * 100
> This works great and looks like this:
> Date | Core
> --
> Jan 1 2005 | $400
> Aug 31 2005 | $500
> --
> Footer +25%
> I have been asked to add in the value from a year ago today but still
> display the change in value from just Jan 1.
> Date | Core
> --
> Aug 31 2004 | $300
> Jan 1 2005 | $400
> Aug 31 2005 | $500
> --
> Footer +25% (Diff between Jan 1 and Aug 31 2005)
> How would I calc the % change in the footer. My formula will not work as the
> "First" value is a year ago today not Jan 1. Is there a "Middle" function ?
> :) :)
> Thoughts ?
> Thanks in Advance
> Pete Mitchell
>|||Thanks, good suggestion.
"MJ Taft" wrote:
> maybe you could use groups to accomplish the division of the first row from
> the other two. Then you could just hide the group header and footer of
> group1 and hide the header of group 2. I am not sure how the first and last
> will work with groups ... just a thought
> > Date | Core
> > --
> > Aug 31 2004 | $300 ======== > group 1
> > Jan 1 2005 | $400 ========> group 2
> > Aug 31 2005 | $500 ========> group 2
> > --
> > Footer +25% (Diff between Jan 1 and Aug 31 2005)
>
> "PeteMitchell" wrote:
> > I have a Matrix that always displays two rows of data.
> > One row show values from Jan 1 of the current year.
> > The second row shows values for today.
> >
> > In the foot I show the % the values have changed so YTD with the following
> > formula:
> >
> > =(Last(Fields!Core.Value) - First(Fields!Core.Value)) /
> > First(Fields!Core.Value) * 100
> >
> > This works great and looks like this:
> > Date | Core
> > --
> > Jan 1 2005 | $400
> > Aug 31 2005 | $500
> > --
> > Footer +25%
> >
> > I have been asked to add in the value from a year ago today but still
> > display the change in value from just Jan 1.
> >
> > Date | Core
> > --
> > Aug 31 2004 | $300
> > Jan 1 2005 | $400
> > Aug 31 2005 | $500
> > --
> > Footer +25% (Diff between Jan 1 and Aug 31 2005)
> >
> > How would I calc the % change in the footer. My formula will not work as the
> > "First" value is a year ago today not Jan 1. Is there a "Middle" function ?
> > :) :)
> >
> > Thoughts ?
> >
> > Thanks in Advance
> >
> > Pete Mitchell
> >

2012年2月26日星期日

First INSERT in the transaction is not being committed

Hi All
I am having a strange problem. I have an excel sheet from which I fetch
the data using ADODB. I hava a loop which runs through all rows in the
excel sheet and calls a stored procedure to insert the rows into the
database.
The problem is when the statement oConn.CommitTrans is called, the
first row is not being inserted into the database.
But I am able to see the call to the stored procedure in the SQL
Profiler for the first row in addition to the other rows.
One more thing is, in the SQL Profiler, after the call to the stored
procedure for the first row, I am seeing the following:
SET NO_BROWSETABLE ON
SET FMTONLY ON EXEC spInsert ' ', ' ' SET FMTONLY OFF
set fmtonly off
SET NO_BROWSETABLE OFF
Please help me.
Thanks in advanceI think that SET FMTONLY ON is doing no results appearing. Put on
"hbase19-all@.yahoo.co.in" wrote:

> Hi All
> I am having a strange problem. I have an excel sheet from which I fetch
> the data using ADODB. I hava a loop which runs through all rows in the
> excel sheet and calls a stored procedure to insert the rows into the
> database.
> The problem is when the statement oConn.CommitTrans is called, the
> first row is not being inserted into the database.
> But I am able to see the call to the stored procedure in the SQL
> Profiler for the first row in addition to the other rows.
> One more thing is, in the SQL Profiler, after the call to the stored
> procedure for the first row, I am seeing the following:
> SET NO_BROWSETABLE ON
> SET FMTONLY ON EXEC spInsert ' ', ' ' SET FMTONLY OFF
> set fmtonly off
> SET NO_BROWSETABLE OFF
> Please help me.
> Thanks in advance
>|||It looks like your XL sheet does not have a header row. Try adding a header
row. SET FMTONLY will only return meta-data to the client and it looks like
this call is being made to determine the structure.
--
HTH,
SriSamp
Email: srisamp@.gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp
<hbase19-all@.yahoo.co.in> wrote in message
news:1136794436.468218.270140@.g47g2000cwa.googlegroups.com...
> Hi All
> I am having a strange problem. I have an excel sheet from which I fetch
> the data using ADODB. I hava a loop which runs through all rows in the
> excel sheet and calls a stored procedure to insert the rows into the
> database.
> The problem is when the statement oConn.CommitTrans is called, the
> first row is not being inserted into the database.
> But I am able to see the call to the stored procedure in the SQL
> Profiler for the first row in addition to the other rows.
> One more thing is, in the SQL Profiler, after the call to the stored
> procedure for the first row, I am seeing the following:
> SET NO_BROWSETABLE ON
> SET FMTONLY ON EXEC spInsert ' ', ' ' SET FMTONLY OFF
> set fmtonly off
> SET NO_BROWSETABLE OFF
> Please help me.
> Thanks in advance
>|||Thanks for the reply
The line "SET FMTONLY ON" is appearing automatically. I am not calling
that statement.
Also I found in ms web site that the statement "SET FMTONLY ON" starts
an implicit transaction even if we call "SET implicit_transactions
off". So they suggested MDAC 2.6 latest service pack. I did that. But
even then the problem is persistent.
I copied the series of statements (from BEGIN TRANSACTION to COMMIT
TRANSACTION) from SQL profiler and ran them in SQL Query Analyzer. An
error occurred saying
"The COMMIT TRANSACTION request has no corresponding BEGIN
TRANSACTION".
So I commented out the lines
SET NO_BROWSETABLE ON
SET FMTONLY ON EXEC spInsert ' ', ' ' SET FMTONLY OFF
set fmtonly off
SET NO_BROWSETABLE OFF
and ran the TRANSACTION statements. It worked fine. So the problem
might be in those 4 lines.
Please help me

2012年2月24日星期五

first 7 rows

I have a table sal with the following structure
emp_no int,
dept_no int,
basic_salary money
Is it possible to extract 7 highly paid employed with one SQL statement?
any help will be highly appreciated.select TOP 7
emp_no,
dept_no,
basic_salary
from YourTable
order by basic_salary desc|||how will it calculate highest salary? I mean how system knows to display record based on salary field?|||"order by basic_salary desc"|||the top clause retrieves the rows that would exist at the "Top" of your result set so if your result set was
joe
steve
bill
rob
mary

and you selected the top 3
you would get
joe
steve
bill

the control factor with the top clause is the order by clause
the order by clause sorts the result set either in ascending (ASC) or descending (DESC) order. so if you sorted a salary column asc, the lowest salary would be at the top correct?. and if you selected the top 7 salaries in that example, you would have the 7 lowest salaries.
by sorting the salary column in desc order, you would get the top 7 salaries

please open and read this help file
Books Online{Limiting Result Sets Using TOP and PERCENT}|||how will it calculate highest salary? I mean how system knows to display record based on salary field?

What is the context of the salary table? Does it hold weekly salary data?

Everyone here thinks it's annual.|||Sheesh!

create table sal
(
emp_no int
,dept_no int
,basic_salary money
)

insert into sal values (1 ,10,1000.00)
insert into sal values (2 ,10,2000.00)
insert into sal values (3 ,10,1500.00)
insert into sal values (4 ,10,1200.00)
insert into sal values (5 ,10,1000.00)
insert into sal values (6 ,10,3000.00)
insert into sal values (7 ,10,2200.00)
insert into sal values (8 ,10,1250.00)
insert into sal values (9 ,10,1350.00)
insert into sal values (10 ,10,1000.00)

select * from sal

select top 7 emp_no, dept_no
,Basic_Salary as 'WeeklySalary' --by week
,BiWeeklySalary=(Basic_Salary*2) --BI week
,AnnualSalary=((basic_salary*2)*26) --Annual
from sal
order by AnnualSalary desc|||OK...so what if there's more than 1 salary row per employee?|||...an aggregate query to sum up the salary values.|||...an aggregate query to sum up the salary values.

Thanks you...my point...

Without the DDL of the table we'd be just shooting in the dark

Bang

Yo blind dude..did that hit you?|||Nyah nyah, ya missed me!

You forget that, as the Blindman, I shoot in the dark just fine! :cool:|||okay
since the poster hasnt said anything about it then this post is officially dead.

dont be a malingerer.|||"since the poster hasnt said anything about it then this post is officially dead"?

Like THAT has ever stopped us before...

and "malingerer"?

In the words of Inigo Montoya -
"You keep using that word. I do not think it means what you think it means."

http://dictionary.reference.com/search?q=malingerer|||you killed my father -- prepare to die!|||i know exactly what it means.
you are spending your time posting to a thread that is dead
so you are in effect acting crazy(sick) to get out of the real work here
and that is driving rdjabarov and pat phelan crazy.|||i know exactly what it means.
you are spending your time posting to a thread that is dead
so you are in effect acting crazy(sick) to get out of the real work here
and that is driving rdjabarov and pat phelan crazy.Huh? I seem to keep missing meetings around here!

-PatP|||you killed my father -- prepare to die!

Do you have 6 fingers on your left hand?

That is a great movie

What's with Scott? Are there time issues involved here?

What's officially Dead?|||You are!

Because you killed my father! Prepare to die!

...and Ruprect: Glad you looked up the definition! It pays to enrich your wordpower!|||okay
since the poster hasnt said anything about it then this post is officially dead.

dont be a malingerer.

Hey...he's not even suppose to be here...he's an...an...Oracle developer...

Yo Blind dude..are you feeling OK? (http://www.google.com/search?hl=en&lr=&oi=defmore&q=define:malingerer)|||I have a cough that has been malingering on for weeks now...|||I have a cough that has been malingering on for weeks now...I resemble that remark!

-PatP|||Hey...he's not even suppose to be here...he's an...an...Oracle developer...Its Ok... He can have his kids tell folks that he plays the piano in... Nevermind!

-PatP|||And this thread is only mostly dead...there a difference

To blathe

Have fun stormin the castle boys

I would like to stay and malinger...but I have to go

EDIT: Ya know, this is corral stuff|||Where the heck is a Yak when a guy needs one? I'm off (but you knew that)!

-PatP|||Mostly dead. Now THAT was funny. I wish I'd though of that one, Buttercup.

Can this thread possibly go on? Inconceivable!|||The discussion of this mostle dead thread has moved to the corral

http://www.dbforums.com/showthread.php?p=3978181#post3978181