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

2012年3月22日星期四

Flat file Import performance question

Hi there,

I have a question regarding 2 approaches importing data from a flat text file. I'm taking the approach suggested by Phil Brammer to use a checksum to see whether a row has exists, and if it does check whether it has changed.

http://www.ssistalk.com/2007/03/09/ssis-using-a-checksum-to-determine-if-a-row-has-changed

I would like to hear some opinions on 2 approaches:

1) Importing the data int a temp table first then do the data processing from the temp table.
Or
2) Importing the data by doing the data processing direcly from the text file without placing it in a temp table first.

A hunch told me that it will be faster doing approach 1 but I would like to hear some experienced opinions first Smile

Best regards
Mike

I would think #2 would be *slightly* faster just because there are less components at work.

With that said, I prefer #1 always because it quickly loads the data to a table which I can then use SQL to get the data out. This might be advantageous for sorting the data, filtering the data, joining the data to another table, etc... Basically I like to push as much work off to the database engine that I can. Sure, SSIS can merge (join) data sets together, but the database engine will do a much better job. Also, having the data staged will help me to restart the process should it fail, work in batches (perhaps) by loading more than one file to the table if needed, and guarantee that the data will be there when I need it in an environment that might not guarantee that the file will always be around for use.

|||Thanks Phil,

I really appreciate your valuable input.

Best regards
Mike
|||

If you can afford, I would suggest to test both approaches, in your own environment, and then base your decisions on that way collected (real) data.

Thanks,

Bob

sql

Flat file Import performance question

Hi there,

I have a question regarding 2 approaches importing data from a flat text file. I'm taking the approach suggested by Phil Brammer to use a checksum to see whether a row has exists, and if it does check whether it has changed.

http://www.ssistalk.com/2007/03/09/ssis-using-a-checksum-to-determine-if-a-row-has-changed

I would like to hear some opinions on 2 approaches:

1) Importing the data int a temp table first then do the data processing from the temp table.
Or
2) Importing the data by doing the data processing direcly from the text file without placing it in a temp table first.

A hunch told me that it will be faster doing approach 1 but I would like to hear some experienced opinions first Smile

Best regards
Mike

I would think #2 would be *slightly* faster just because there are less components at work.

With that said, I prefer #1 always because it quickly loads the data to a table which I can then use SQL to get the data out. This might be advantageous for sorting the data, filtering the data, joining the data to another table, etc... Basically I like to push as much work off to the database engine that I can. Sure, SSIS can merge (join) data sets together, but the database engine will do a much better job. Also, having the data staged will help me to restart the process should it fail, work in batches (perhaps) by loading more than one file to the table if needed, and guarantee that the data will be there when I need it in an environment that might not guarantee that the file will always be around for use.

|||Thanks Phil,

I really appreciate your valuable input.

Best regards
Mike
|||

If you can afford, I would suggest to test both approaches, in your own environment, and then base your decisions on that way collected (real) data.

Thanks,

Bob

2012年3月21日星期三

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World

NULL

NULL

NULL

This

is

a

test

NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World{CR}{LF}This

is

a

test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 | | Col2 | | Col3 | | Col4 | | Col5 | The Quick Brown Fox Jumps Hello World NULL NULL NULL This is a test NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 | | Col2 | | Col3 | | Col4 | | Col5 | The Quick Brown Fox Jumps Hello World{CR}{LF}This is a test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World

NULL

NULL

NULL

This

is

a

test

NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World{CR}{LF}This

is

a

test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

sql

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World

NULL

NULL

NULL

This

is

a

test

NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World{CR}{LF}This

is

a

test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World

NULL

NULL

NULL

This

is

a

test

NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World{CR}{LF}This

is

a

test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 | | Col2 | | Col3 | | Col4 | | Col5 | The Quick Brown Fox Jumps Hello World NULL NULL NULL This is a test NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 | | Col2 | | Col3 | | Col4 | | Col5 | The Quick Brown Fox Jumps Hello World{CR}{LF}This is a test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World

NULL

NULL

NULL

This

is

a

test

NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World{CR}{LF}This

is

a

test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World

NULL

NULL

NULL

This

is

a

test

NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 |

| Col2 |

| Col3 |

| Col4 |

| Col5 |

The

Quick

Brown

Fox

Jumps

Hello

World{CR}{LF}This

is

a

test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

sql

Flat File and uneven number of columns

Please leave feedback for Microsoft regarding this problem at https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=126493

Ok I'm sure it just me, SSIS has been great so far....but how can you import a straight CSV file with and uneven column count.

For example: (assume CR LF row delimiter)

The,Quick,Brown,Fox,Jumps
Hello,World
This,is,a,test

"Normally" I'd expect this

| Col1 | | Col2 | | Col3 | | Col4 | | Col5 | The Quick Brown Fox Jumps Hello World NULL NULL NULL This is a test NULL

Ok but what we get is the row delimiter is ignored in preference for the column delimiter and the row delimiter gets sucked into the column and the next row starts to get layed down.

So we get

| Col1 | | Col2 | | Col3 | | Col4 | | Col5 | The Quick Brown Fox Jumps Hello World{CR}{LF}This is a test

I'm I not seeing a tick box somewhere that says "over here if you want to terminate a row on the row delimiter even if all columns aren't full and we'll pad NULLs in rest of the row columns which you can fix in the flow transformations"

I'm sure it's there.....help!

(By the way SSIS team, great job on the package love using it)

Try using ragged right instead of delimited.

Thanks,

Matt

|||

Ah see if only it was that simple Matt. "Ragged right files are files in which every column has a fixed width, except for the last column, which is delimited by the row delimiter."

So the only thing which can be Ragged in fact is the last column. In my example I've purposely put varying column widths so the old "Ragged Right" doesn’t apply (this is more the norm for ragged files).

So any ideas how this is going to work in SSIS...I must be missing something simple here this is a very common problem that the old DTS, Excel, Access, and other programs deal with quite well.

help!

|||

Unfortunately we only support ragged right for fixed width so for this scenario you would have to read it as a single column and then split it using a script component or you could write a custom component that split it.

Matt

|||

but this is a bug or changed behavior from the old sql server 2000 dts which when you had a comma or tab deliminited file some of the rows had extra columns after the last valid one.. it ignored those extra columns.

the new functionality is to instead append the commas/delimiters into the data pulled in from the last column..

This is causing us major grief becuase now none of our dts's work in the new sql server 2005 so it is not backwards compatible..

|||

This is similar to an issure raised the other day. I produced a sample package on how to handle this.

http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||

I'm with you Igkahn. It's a bug. No way is this a feature! This is killing us too. If I have to script this as set out below then something fundimentally is wrong with SSIS. I cut one of our large SQL 2000 servers over to SQL 2005 and we are stopping there until fixes are supplied for errors like this. I'm now having to use the SQL 2000 DTS instead of the nice looking however functionality poor SSIS.

Please get this fixed.

Garry Swan
Information Systems Manager
CSIRO
Australia

|||

If you feel strongly about it then you should raise it through the Feedback centre and through your MS representative if you have one.

|||

Calling it a bug implies that is supposed to do something else and I'm not sure that is the case. I'm not denying that it MIGHT be a bug - hopefully Matt will reply again and tell us (By the way, just because some behaviour was present in DTS, you shouldn't assume the same would be true of SSIS. This is a replacement, not an upgrade).

Regardless, I can understand why this is causing headache. Have you logged it at the feedback center (http://lab.msdn.microsoft.com/productfeedback/default.aspx)? If not, then you shouldn't expect that the feature will make it into the next version.

I don't understand why you call SSIS functionally poor. As Simon explained this can still be achieved quite easily. Surely the fact that there is "more than one way to skin a cat" so to speak means the product is functionally rich as opposed to poor? Is the fact that something cannot be achieved using your "preferred" method really prohibiting you from moving to a superior product?

-Jamie

|||

From my research there has been a lot of posts about this issue in the last couple of months. But im still looking for a proper solution, is there a fix available? Is there a code sample available for a SSIS source component or whatnot, that threats uneven columns properly?

I've looked through the sample for the source component and could not get it to run (something about no compatible component in the dll)

Since people do need to import data from delimited files very often, SSIS should be expending the functionality of what there was in the DTS world... but in this case it was decided to limit it. Whoever came up with the delimiter for each column must have been so proud of himself that he generlized and removed the need for a row delimiter....

Well you haven't, and we want it back. :) It's causing many people, a lot of greef.

Or at least release the source for a flat file handler which people can customize to their liking.

There is so many flat file formats out there.... Why be so restrictive when dealing with them?

|||

Whats wrong with the sample I have provided.

SSIS focus was on building a framework that was performant, scalable and extensible. For this reason the components out of the box don't satisfy everyones requirements. But I have shown how it is very easy to extend SSIS with a script component to achieve your goal.

If you want a more polished solution you can develop your own custom component but that is another level of complexity that really isn't needed due to the power of the script component.

|||

Someone mentioned that the code provided by Sabin didn't work for him/her. I have not tried that code.

Here is a version (another way to skin the cat) that can be tried. Please note that your first row should contain all the column names for this to work. This script assumes that the input is configured in a way that all data on one row constitute a column. So basically, there is just one column in each row. The output of this script is also one column in each row. However, the output created by this script can be "understood" by SSIS file connection manager. Finally, assumption is that "tab" is column delimiter. You can change that below, if that is not the case.

Private dataRow As Boolean = False

Public Function AppendMissingTabs(ByVal Row As InputBuffer) As String

Dim columns As String() = Nothing
Dim outputRow As String = Nothing
Dim outputString As String = Nothing
Dim buffer As StringBuilder = New StringBuilder()

buffer.Append(Row.BigSingleColumn)

columns = Row.BigSingleColumn.Split(New [Char]() {Chr(9)})

If Not dataRow Then
columnCount = columns.Length
End If

Dim N As Integer
If columns.Length < columnCount Then

For N = 1 To columnCount - columns.Length Step 1
buffer.Append(Chr(9))
Next N

End If

dataRow = True

Return buffer.ToString()

End Function

|||

It comes down to if I tell a system that my row finishes with a crlf I don't want it to override my decision and pull the crlf into the data. Why would I want the row delimiter in the data?!? Is this a feature people needed and the SSIS team decided the former was so last week that this new functionality was, in fact, a better solution path...I just doubt it. The required functionality is the way Excel, DTS, Access and many other apps handle this data import. Why is SSIS pulling crlf into my data when I've said this is the end of the row?!?. Just stop and move onto the next row. Put that functionality back in and you've got a great delimited file importer.

Garry Swan

MCDBA

|||

What you have actually said is that your column finishes with your delimiter. The flat file source then looks for that delimiter to end the column. The CRLF is not defined as the record delimiter but the delimiter of the last column.

I know that doesn't solve the problem but should explain the reason for the situation.

I still stand by the fact that if you want this functionality using the script component is a valid solution.

|||

Last night I uploaded a custom source adapter to SourceForge that would let you parse this file with regular expressions.

http://sourceforge.net/projects/textregexsource

Just connect a file connection manager to it and set a regular expression, and it could produce what you want.

I think a regex like (?'Col1'\w+),*(?'Col2'\w*),*(?'Col3'\w*),*(?'Col4'\w*),*(?'Col5'\w*)\n

might do the trick, though it might need tweaking.

Geof

2012年3月19日星期一

Fixing a messy database after the fact...?

2 questions, actually:

I am new to database design and a lot of things never made any sense to me regarding relationships and such. I have been working on a very large design that started out well enough, but as tables were added a lot of organization fell by the wayside. Now that I am getting closer to the end, I am finding a lot of places where there should be Foreign keys, maybe some triggers, etc (I have the same data item in 5 different places, when it is deleted in one place it must go from all). Assuming that the datatypes and sizes are identical for the duplicated bits of data, can I go about making FK-PK relationships and such now that there is a lot of stuff in the database, or do I have to start from scratch and rebuild the whole thing.

The other question is much more simple:

How do I make multiple rows "unique". I have a primary key, and an identity column, but I can't add a secong primary key, and Enterprise Manager only lets me make 'int' datatypes identity columns. I have tried the "add constraints" but it asks for an expression and I have no idea what the syntax might be.

Any help is appreciated.Try downloading AdventureWorks for SQL Server 2000 from the first link, copy the installation file into Query Analyzer and execute it. It is an 87 table Database using the Peter Chen ERD model. The second is PPT slides with the book used to create it, only 143 pages but it has a lot of sample Catalogs that will make things a little easier for you. The book is dry and abstract. Hope this helps.

http://www.microsoft.com/downloads/details.aspx?familyid=487c9c23-2356-436e-94a8-2bfb66f0abdc&languageid=f49e8428-7071-4979-8a67-3cffcb0c2524&displaylang=en

http://wings.buffalo.edu/mgmt/courses/mgtsand/data.html

Kind regards,
Gift Peddie

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.
>

2012年3月9日星期五

Fix dependencies during or after renaming

The previous post regarding dependencies reminded me of another bugger I come
up with from time to time. SQL Server allows us to rename objects via a
system stored procedure (I usually use an ADP front-end that presumably calls
the same procedure), but after the rename, I find singnificant strangeness.

For instance, triggers are still connected to the tables, but the trigger text
still refers to the old table name. Views and stored procedures dependent on
the table are broken, and are not fixed by even by restarting the server,
though I thought the cached plans were supposed to be dumped on shut-down,
then recreated on demand later.

Is there some tool or technique to rename a table and automatically detect and
properly drop/rebuild dependent triggers, views, stored procedures,
relationships, and anything else I'm not thinking of?

Oh yeah, and there are extended properties to deal with as well, but I guess
that's intractible unless we know what client build them (e.g. Access ADP),
and what it expects to be recorded there, but I suppose it would be nice to
just dump them rather than leave them there possibly corrupted from a client's
persective.Steve Jorgensen wrote:

> The previous post regarding dependencies reminded me of another bugger I come
> up with from time to time. SQL Server allows us to rename objects via a
> system stored procedure (I usually use an ADP front-end that presumably calls
> the same procedure), but after the rename, I find singnificant strangeness.
> For instance, triggers are still connected to the tables, but the trigger text
> still refers to the old table name. Views and stored procedures dependent on
> the table are broken, and are not fixed by even by restarting the server,
> though I thought the cached plans were supposed to be dumped on shut-down,
> then recreated on demand later.
> Is there some tool or technique to rename a table and automatically detect and
> properly drop/rebuild dependent triggers, views, stored procedures,
> relationships, and anything else I'm not thinking of?
> Oh yeah, and there are extended properties to deal with as well, but I guess
> that's intractible unless we know what client build them (e.g. Access ADP),
> and what it expects to be recorded there, but I suppose it would be nice to
> just dump them rather than leave them there possibly corrupted from a client's
> persective.

One thing I know about views, if you rename a view, you best double
click it in EM and rename it in the create statement as well otherwise
it will get renamed back to the old name if ever you script it.
(checks his 4 views, nope, that's not why that happened).|||On Fri, 23 Jan 2004 11:01:27 GMT, Steve Jorgensen <nospam@.nospam.nospam>
wrote:

>The previous post regarding dependencies reminded me of another bugger I come
>up with from time to time. SQL Server allows us to rename objects via a
>system stored procedure (I usually use an ADP front-end that presumably calls
>the same procedure), but after the rename, I find singnificant strangeness.
>For instance, triggers are still connected to the tables, but the trigger text
>still refers to the old table name. Views and stored procedures dependent on
>the table are broken, and are not fixed by even by restarting the server,
>though I thought the cached plans were supposed to be dumped on shut-down,
>then recreated on demand later.

Oh yeah, I guess the views and procedures don't get the table names updated in
the code, so that one's obvious (though I'd still like an automated way to fix
it). What -was- confusing about that was why renaming a -column- causes
problems for stored procedures and views, even after a restart, even if the
procedure or view is uing an asterisk in the select and not directly
referencing the column in question.|||Steve Jorgensen (nospam@.nospam.nospam) writes:
> Oh yeah, I guess the views and procedures don't get the table names
> updated in the code, so that one's obvious (though I'd still like an
> automated way to fix it). What -was- confusing about that was why
> renaming a -column- causes problems for stored procedures and views,
> even after a restart, even if the procedure or view is uing an asterisk
> in the select and not directly referencing the column in question.

Hm, I wrote this procedure:

create proc test_sp as select * from test

Which I subsequently executed. And I found that test had two columns
'mystring' and 'col'.

Then I ran:

sp_rename 'test.mystring', hisstring, 'column'

Without restarting the server, I successfully ran the procedure, and
the column was called 'hisstring'. I then created:

create view test_view as select * from test

And then:

sp_rename 'test.hisstring', herstring, 'column'

I was able to select from the view after this. However in the view
the column was still named 'hisstring'. This is because SQL Server
stores the name of the columns in the view in the system tables. This
can be remedied with:

exec sp_refreshview test_view

Finally, I would like to point out that I, and many with me, find it
to be bad coding practice to use SELECT * in production code.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Steve Jorgensen (nospam@.nospam.nospam) writes:
> The previous post regarding dependencies reminded me of another bugger I
> come up with from time to time. SQL Server allows us to rename objects
> via a system stored procedure (I usually use an ADP front-end that
> presumably calls the same procedure), but after the rename, I find
> singnificant strangeness.
> For instance, triggers are still connected to the tables, but the
> trigger text still refers to the old table name. Views and stored
> procedures dependent on the table are broken, and are not fixed by even
> by restarting the server, though I thought the cached plans were
> supposed to be dumped on shut-down, then recreated on demand later.
> Is there some tool or technique to rename a table and automatically
> detect and properly drop/rebuild dependent triggers, views, stored
> procedures, relationships, and anything else I'm not thinking of?

The major enterprise data-modelling tools offers such features.

If you have your code under version-control - and this is what you should -
you could run some search/replace tool, provided that the old column
name is significant enough.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp