Showing posts with label components. Show all posts
Showing posts with label components. Show all posts

Friday, March 30, 2012

Moving whole rows in the script component

I am new to script components. I would like to make a simple filter that either passes a row through untouched or eliminates it. I have my input and output buffers set the same, and I have it set as asynchronous. Now these are big rows. Is there a painless way to copy all columns from the input to output buffer, or do I have to do a "Output0Buffer.Col1 = Row.Col1" for each column?

No painless way that I am aware off.

A question: why are you doing this in a script component? This seems more suited to a conditional split. Just send the rows to be eliminated to an output that isn't connected to another component, and they are gone.

If you have to use a script component (perhaps because of extremely complex logic), you can still use synchronous outputs (which means all your columns will carry over). Just create two outputs (both synchronous) and send rows you want to one, rows to discard to another. See Jamie's post here for some info on this: http://blogs.conchango.com/jamiethomson/archive/2005/09/05/SSIS-Nugget_3A00_-Multiple-outputs-from-a-synchronous-script-transform.aspx

|||I did simplify some here. I want to sort removing duplicates of an ID column, but of the dupes, I want it to select the one with the earliest value in a date column. I tried sorting by the date, then by the ID (removing duplicates), but the date sorting was lost, of course. So the conditional split doesn't work because the decision is dependent on more than one row.

I see a way to do this with SQL, making a few views, but it ended up being overly complicated. I also have it working synchronously as you suggested. That was an easy solution! That's the one I'll keep.

I guess I liked the idea of it working asynchronous more at first, but I didn't have a good reason why! I suppose it's faster to code and faster to process doing it synchronously.

Thanks for the quick response.
|||For future reference, here's all I had to do:

Sorted the dataflow coming in on the ID that I wanted to be unique (DocumentUniqueID).
Connected up a new Script Component.
Checked off all the Input Columns (and left them as ReadOnly).
Added an Output.
Set its SynchronousInputID to "Input 0".
Set its ExclusionGroup to 1.
Added this code to the script:

Code Snippet

Public Class ScriptMain
Inherits UserComponent

Private lastUniqueID As String

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
If Row.DocumentUniqueID = lastUniqueID Then
Row.DirectRowToOutput1()
End If

lastUniqueID = Row.DocumentUniqueID
End Sub

End Class


|||

If the source data is in Oracle, SQL Server 2005 or any other DB that has rank() function; you could solve the problem with plain SQL. You can generate an extra column called, let's say, MyRank that will sort each set of duplicate IDs using the given criteria; in you case date. Then you use the conditional split based on MyRank column. I talked about it in this post:

http://rafael-salas.blogspot.com/2007/04/remove-duplicates-using-t-sql-rank.html

|||

Rafael Salas wrote:

If the source data is in Oracle, SQL Server 2005 or any other DB that has rank() function; you could solve the problem with plain SQL. You can generate an extra column called, let's say, MyRank that will sort each set of duplicate IDs using the given criteria; in you case date. Then you use the conditional split based on MyRank column. I talked about it in this post:

http://rafael-salas.blogspot.com/2007/04/remove-duplicates-using-t-sql-rank.html

That's an even better solution. RANK() isn't a function I've used extensively, I overlooked it. Thanks for the tip.
sql

Monday, March 19, 2012

Moving SQL Server Components

Hi Everyone,
We have a new dedicated server for SQL operations. I'm moving all of the objects over to the new server: databases, jobs, alerts, operators, logins. While testing the transfer, I noticed that the logins do not have the access to the databases and roles
are not set. Considering I used the stored procedure in KB article 246133, it should have kept the same database accesses and db roles. Any ideas on this one?
Should I be moving these objects in a specific order for more accurate and optimal results? Does it make a difference?
Thanks in advance.
Larry
It does not really matter what order you transfer things. You mentioned
that you followed the directions within
http://support.microsoft.com/?id=246133. The users and the permissions
should be correct after everything is up-and-running. If not, you could try
sp_change_users_login.
You mentioned that you are using scripts to transfer all "components." I am
not sure what you mean, but you might be able to use a variety of methods to
move the various objects.
Here are some other links that you may find helpful:
INF: Disaster Recovery Articles for Microsoft SQL Server
http://www.support.microsoft.com/?id=307775
INF: Moving SQL Server databases to a new location with Detach/Attach
http://www.support.microsoft.com/?id=224071
HOW TO: Move Databases Between Computers That Are Running SQL Server
http://www.support.microsoft.com/?id=314546
INF: Using the WITH MOVE Option with the RESTORE Statement
http://support.microsoft.com/?id=221465
PRB: User Logon and/or Permission Errors After Restoring Dump
http://www.support.microsoft.com/?id=168001
HOW TO: Transfer Logins and Passwords Between Instances of SQL Server
http://www.support.microsoft.com/?id=246133
PRB: "Troubleshooting Orphaned Users" Topic in Books Online is Incomplete
http://www.support.microsoft.com/?id=274188
How to Resolve Permission Issues When a Database Is Moved Between SQL
Servers
http://www.support.microsoft.com/?id=240872
SAMPLE: Mapsids.exe Helps Map SIDs Between User and Master Databases When
Database Is Moved
http://www.support.microsoft.com/?id=298897
Utility to map users to the correct login
http://www.dbmaint.com/SyncSqlLogins.asp
Keith
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:7007F18A-5363-4F85-A411-C129E601CFF8@.microsoft.com...
> Hi Everyone,
> We have a new dedicated server for SQL operations. I'm moving all of the
objects over to the new server: databases, jobs, alerts, operators, logins.
While testing the transfer, I noticed that the logins do not have the access
to the databases and roles are not set. Considering I used the stored
procedure in KB article 246133, it should have kept the same database
accesses and db roles. Any ideas on this one?
> Should I be moving these objects in a specific order for more accurate and
optimal results? Does it make a difference?
> Thanks in advance.
> Larry

Moving SQL Server Components

Hi Everyone,
We have a new dedicated server for SQL operations. I'm moving all of the ob
jects over to the new server: databases, jobs, alerts, operators, logins.
While testing the transfer, I noticed that the logins do not have the access
to the databases and roles
are not set. Considering I used the stored procedure in KB article 246133,
it should have kept the same database accesses and db roles. Any ideas on t
his one?
Should I be moving these objects in a specific order for more accurate and o
ptimal results? Does it make a difference?
Thanks in advance.
LarryIt does not really matter what order you transfer things. You mentioned
that you followed the directions within
http://support.microsoft.com/?id=246133. The users and the permissions
should be correct after everything is up-and-running. If not, you could try
sp_change_users_login.
You mentioned that you are using scripts to transfer all "components." I am
not sure what you mean, but you might be able to use a variety of methods to
move the various objects.
Here are some other links that you may find helpful:
INF: Disaster Recovery Articles for Microsoft SQL Server
http://www.support.microsoft.com/?id=307775
INF: Moving SQL Server databases to a new location with Detach/Attach
http://www.support.microsoft.com/?id=224071
HOW TO: Move Databases Between Computers That Are Running SQL Server
http://www.support.microsoft.com/?id=314546
INF: Using the WITH MOVE Option with the RESTORE Statement
http://support.microsoft.com/?id=221465
PRB: User Logon and/or Permission Errors After Restoring Dump
http://www.support.microsoft.com/?id=168001
HOW TO: Transfer Logins and Passwords Between Instances of SQL Server
http://www.support.microsoft.com/?id=246133
PRB: "Troubleshooting Orphaned Users" Topic in Books Online is Incomplete
http://www.support.microsoft.com/?id=274188
How to Resolve Permission Issues When a Database Is Moved Between SQL
Servers
http://www.support.microsoft.com/?id=240872
SAMPLE: Mapsids.exe Helps Map SIDs Between User and Master Databases When
Database Is Moved
http://www.support.microsoft.com/?id=298897
Utility to map users to the correct login
http://www.dbmaint.com/SyncSqlLogins.asp
Keith
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:7007F18A-5363-4F85-A411-C129E601CFF8@.microsoft.com...
> Hi Everyone,
> We have a new dedicated server for SQL operations. I'm moving all of the
objects over to the new server: databases, jobs, alerts, operators, logins.
While testing the transfer, I noticed that the logins do not have the access
to the databases and roles are not set. Considering I used the stored
procedure in KB article 246133, it should have kept the same database
accesses and db roles. Any ideas on this one?
> Should I be moving these objects in a specific order for more accurate and
optimal results? Does it make a difference?
> Thanks in advance.
> Larry

Moving SQL Objects

Hi Everyone,
We've setup a new server to be used for SQL Server. I'm using scripts to tr
ansfer all of the components. I was wondering what would be the best order
in which to transfer the objects: databases, jobs, alerts, operators, login
s. Is there an order in wh
ich these should be done for the most accurate and optimal results? Does it
matter? I noticed that when I transfer the logins, the users database acce
ss and roles are not following along.
Thanks in advance.
LarryIt does not really matter what order you transfer things. You mentioned
that you followed the directions within
http://support.microsoft.com/?id=246133. The users and the permissions
should be correct after everything is up-and-running. If not, you could try
sp_change_users_login.
You mentioned that you are using scripts to transfer all "components." I am
not sure what you mean, but you might be able to use a variety of methods to
move the various objects.
Here are some other links that you may find helpful:
INF: Disaster Recovery Articles for Microsoft SQL Server
http://www.support.microsoft.com/?id=307775
INF: Moving SQL Server databases to a new location with Detach/Attach
http://www.support.microsoft.com/?id=224071
HOW TO: Move Databases Between Computers That Are Running SQL Server
http://www.support.microsoft.com/?id=314546
INF: Using the WITH MOVE Option with the RESTORE Statement
http://support.microsoft.com/?id=221465
PRB: User Logon and/or Permission Errors After Restoring Dump
http://www.support.microsoft.com/?id=168001
HOW TO: Transfer Logins and Passwords Between Instances of SQL Server
http://www.support.microsoft.com/?id=246133
PRB: "Troubleshooting Orphaned Users" Topic in Books Online is Incomplete
http://www.support.microsoft.com/?id=274188
How to Resolve Permission Issues When a Database Is Moved Between SQL
Servers
http://www.support.microsoft.com/?id=240872
SAMPLE: Mapsids.exe Helps Map SIDs Between User and Master Databases When
Database Is Moved
http://www.support.microsoft.com/?id=298897
Utility to map users to the correct login
http://www.dbmaint.com/SyncSqlLogins.asp
Keith
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:3AA43999-8696-42CD-BA63-6005479C5F3D@.microsoft.com...
> Hi Everyone,
> We've setup a new server to be used for SQL Server. I'm using scripts to
transfer all of the components. I was wondering what would be the best
order in which to transfer the objects: databases, jobs, alerts, operators,
logins. Is there an order in which these should be done for the most
accurate and optimal results? Does it matter? I noticed that when I
transfer the logins, the users database access and roles are not following
along.
> Thanks in advance.
> Larry|||I would transfer the logins, databases, operators, then jobs and alerts.
The reason I say this is this way all logins will be created prior to any
objects being created that depend on logins being available. I also would
do operators first, since jobs or alerts might need to operators created
first if they send messages to operators.
As far as the roles for logins, they are mainly in the databases. Although
you could have server roles assigned. I don't know of a method to script
the server roles.
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:3AA43999-8696-42CD-BA63-6005479C5F3D@.microsoft.com...
> Hi Everyone,
> We've setup a new server to be used for SQL Server. I'm using scripts to
transfer all of the components. I was wondering what would be the best
order in which to transfer the objects: databases, jobs, alerts, operators,
logins. Is there an order in which these should be done for the most
accurate and optimal results? Does it matter? I noticed that when I
transfer the logins, the users database access and roles are not following
along.
> Thanks in advance.
> Larry

Moving SQL Objects

Hi Everyone,
We've setup a new server to be used for SQL Server. I'm using scripts to transfer all of the components. I was wondering what would be the best order in which to transfer the objects: databases, jobs, alerts, operators, logins. Is there an order in wh
ich these should be done for the most accurate and optimal results? Does it matter? I noticed that when I transfer the logins, the users database access and roles are not following along.
Thanks in advance.
Larry
It does not really matter what order you transfer things. You mentioned
that you followed the directions within
http://support.microsoft.com/?id=246133. The users and the permissions
should be correct after everything is up-and-running. If not, you could try
sp_change_users_login.
You mentioned that you are using scripts to transfer all "components." I am
not sure what you mean, but you might be able to use a variety of methods to
move the various objects.
Here are some other links that you may find helpful:
INF: Disaster Recovery Articles for Microsoft SQL Server
http://www.support.microsoft.com/?id=307775
INF: Moving SQL Server databases to a new location with Detach/Attach
http://www.support.microsoft.com/?id=224071
HOW TO: Move Databases Between Computers That Are Running SQL Server
http://www.support.microsoft.com/?id=314546
INF: Using the WITH MOVE Option with the RESTORE Statement
http://support.microsoft.com/?id=221465
PRB: User Logon and/or Permission Errors After Restoring Dump
http://www.support.microsoft.com/?id=168001
HOW TO: Transfer Logins and Passwords Between Instances of SQL Server
http://www.support.microsoft.com/?id=246133
PRB: "Troubleshooting Orphaned Users" Topic in Books Online is Incomplete
http://www.support.microsoft.com/?id=274188
How to Resolve Permission Issues When a Database Is Moved Between SQL
Servers
http://www.support.microsoft.com/?id=240872
SAMPLE: Mapsids.exe Helps Map SIDs Between User and Master Databases When
Database Is Moved
http://www.support.microsoft.com/?id=298897
Utility to map users to the correct login
http://www.dbmaint.com/SyncSqlLogins.asp
Keith
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:3AA43999-8696-42CD-BA63-6005479C5F3D@.microsoft.com...
> Hi Everyone,
> We've setup a new server to be used for SQL Server. I'm using scripts to
transfer all of the components. I was wondering what would be the best
order in which to transfer the objects: databases, jobs, alerts, operators,
logins. Is there an order in which these should be done for the most
accurate and optimal results? Does it matter? I noticed that when I
transfer the logins, the users database access and roles are not following
along.
> Thanks in advance.
> Larry
|||I would transfer the logins, databases, operators, then jobs and alerts.
The reason I say this is this way all logins will be created prior to any
objects being created that depend on logins being available. I also would
do operators first, since jobs or alerts might need to operators created
first if they send messages to operators.
As far as the roles for logins, they are mainly in the databases. Although
you could have server roles assigned. I don't know of a method to script
the server roles.
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:3AA43999-8696-42CD-BA63-6005479C5F3D@.microsoft.com...
> Hi Everyone,
> We've setup a new server to be used for SQL Server. I'm using scripts to
transfer all of the components. I was wondering what would be the best
order in which to transfer the objects: databases, jobs, alerts, operators,
logins. Is there an order in which these should be done for the most
accurate and optimal results? Does it matter? I noticed that when I
transfer the logins, the users database access and roles are not following
along.
> Thanks in advance.
> Larry