Showing posts with label management. Show all posts
Showing posts with label management. Show all posts

Friday, March 30, 2012

Scriptifying in SQL 2005 Express

How does one scriptify all database objects using SQL Server 2005 Express / Server Management Studio Express?

I can see how to scriptify individual objects, but I'm not so keen on doing that for 200+ objects!

Thanks in advance

Dave

davebartlett.net

1. Right button on database

2. Select Tasks

3. select Generate Scripts

4. follow the instructions

Madhu

|||

Thanks, that saved a lot of time.

Do you know how to script all objects, but generate 1 script file per object?

The Wizard doesn't seem to allow that mode, it seems to put all generated scripts in a single file, which is difficult to navigate through when editing.

|||

for that you should apply SP2 ... sp2 have all the feature like in SQL 2000... in "OutPut Option window you have all these features... if it is not there in your machine means, yours is not SP2

Madhu

|||

Yes, I've installed SP2 and I can now scriptify each object to a separate file.

This is a great feature, thanks for your help.

Wednesday, March 28, 2012

Scriptifying in SQL 2005 Express

How does one scriptify all database objects using SQL Server 2005 Express / Server Management Studio Express?

I can see how to scriptify individual objects, but I'm not so keen on doing that for 200+ objects!

Thanks in advance

Dave

davebartlett.net

1. Right button on database

2. Select Tasks

3. select Generate Scripts

4. follow the instructions

Madhu

|||

Thanks, that saved a lot of time.

Do you know how to script all objects, but generate 1 script file per object?

The Wizard doesn't seem to allow that mode, it seems to put all generated scripts in a single file, which is difficult to navigate through when editing.

|||

for that you should apply SP2 ... sp2 have all the feature like in SQL 2000... in "OutPut Option window you have all these features... if it is not there in your machine means, yours is not SP2

Madhu

|||

Yes, I've installed SP2 and I can now scriptify each object to a separate file.

This is a great feature, thanks for your help.

Monday, March 26, 2012

Script to export tables,store procedures and data in SQL Server Management Studio Expres

how i can do a script to export tables,store procedures and data in SQL Server Management Studio Expres

I just arrive to do a script for tables and stores procedures

help please

hi,

this feature is not supported in SQL Server Management Studio (and SSMSExpress too)... you can only script out the DDL to re-create the initial objects but not to populate them..

if you like, you can have a look at 2 free prjs of mine at http://www.asql.biz/en/Download2005.aspx..

amScript is to generate DDL scripts, where amInsert is to generate INSERT INTO scripts to populate existing tables...

regards

|||

Our web hosting team is working on a tool that will do much of this as well. You can check out their progress by downloading the most recent CTP of the Database Publishing Wizard from CodePlex. You'll find information on the site explaining what the tool does and how it works.

Mike

Friday, March 23, 2012

SCRIPT TO ALTER for functions in a SQL 2000

I installed SQL Server Management Express and try to access to a SQL Server 2000 remotly.

I connected correctly but when I try to alter an existing function, I get the following error message:

TITLE: Microsoft SQL Server Management Studio Express

Property AnsiNullsStatus is not available for UserDefinedFunction '[dbo].[functionName]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights. (Microsoft.SqlServer.Express.Smo)

Note that functionName contain the correct function name.

Can someone confirm me that SQL Server Managmt Express can not alter function from previous SQL version or may I need to set some parameters on Server 2000.

Thanks

I'm moving this to the Tools forum.

Mike

sql

Wednesday, March 21, 2012

Script Task debug error

Good afternoon -

Info:

Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services Client Tools 2005.090.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600

I am trying to debug a script task within a SSIS package by setting a breakpoint within the design window of teh script taks and I get the following error:

EventType : clr20r3 P1 : dtattach.exe P2 : 9.0.242.0 P3 : 434f5e26
P4 : microsoft.sqlserver.scripttask P5 : 9.0.242.0 P6 : 434f5e02
P7 : 4f P8 : 0 P9 : pszqoadhx1u5zahbhohghldgiy4qixhx

Other packages within the solution have script tasks and I can debug these with no problem. This particular script task has constanly given me this error.

Please let me know if there is additional information that I need to provide to facilitate a solution.

Respectfully,

James

I kind of figured nobody would tackle this...|||Looks like a nasty error, and one that should not occur. You could try breaking down the task to try and isolate the cause, as obviously not all scripts do it, so what part of this one does cause the issue. Even if you find it, unless you can change what you are doing it will not fix it, but you may then be able to log a support case with MS giving them more information. You could just log a call now, it does seem like something is very wrong, since the normal task/VSA error handling is not catching this.|||

Thanks for the reply. I will log an incident with MS to resolve this. It's odd because the script task functions properly, I just can't debug this particular task. When the debugger begins, the text displayed is from a totally different script task and a box pops up saying that, "Microsoft Visual Studio has lost the link to your application and will attempt to recover when you logoff."

Respectfully,

James

|||

Hi

I had a similar issue, the details of which can be found below. I believe my issue was around a line of code that assigned a string containing a string of xml directly to a dts string variable:

Dts.Variables("CaseDetail").Value = myNode.OuterXml.ToString()

I removed the above line, copied the script, deleted the script task, added a new script task and then pasted back in the code without the above line. The code then debugged fine but I still needed to save the OuterXml so I assigned it to a string variable first:

Dim outerXML As String

outerXML = myNode.OuterXml.ToString()

Dts.Variables("CaseDetail").Value = outerXML

This seems to work ok and debugs too. I'm not sure why I couldn't assign directly to the dts variable, but I'm more of a c# man these days, so maybe my VB skills are to blame.

My Error:

Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 28/06/2006
Time: 14:01:16
User: N/A
Computer: ****
Description:
EventType clr20r3, P1 dtattach.exe, P2 9.0.242.0, P3 434f5e26, P4 microsoft.sqlserver.scripttask, P5 9.0.242.0, P6 434f5e02, P7 4f, P8 0, P9 pszqoadhx1u5zahbhohghldgiy4qixhx, P10 NIL.
Data:

|||

Was facing the same issue even after trying all of the above.

Have found workaround for this annoying problem

Everytime you get this error, right click on the problematic project in solution explorer and select 'clean' and then select 'rebuild'

Debugging should then work ok.

ta

arun

|||

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

|||

MohitGupta wrote:

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

If someone replies with an answer please could you mark it as such. This helps when other people are searchig the forums for answers to their own questions.

Thanks

|||

Hello,

I've got the same problem here. Previous week i had no probleme, now i'm not able to put a breakpoint in any of my scripts. This cause a crash... it is very annoying

Version of server 9.0.3153 32 bit

Version of client 9.0.3142 32 bit (last sp2 + hotfixes) - dotnet framework 2.0 + sp2

What change since then : update in windows defender...

I suspect a problem with the antivirus, or windows defender preventing the script from debugging...

sql

Script Task debug error

Good afternoon -

Info:

Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services Client Tools 2005.090.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600

I am trying to debug a script task within a SSIS package by setting a breakpoint within the design window of teh script taks and I get the following error:

EventType : clr20r3 P1 : dtattach.exe P2 : 9.0.242.0 P3 : 434f5e26
P4 : microsoft.sqlserver.scripttask P5 : 9.0.242.0 P6 : 434f5e02
P7 : 4f P8 : 0 P9 : pszqoadhx1u5zahbhohghldgiy4qixhx

Other packages within the solution have script tasks and I can debug these with no problem. This particular script task has constanly given me this error.

Please let me know if there is additional information that I need to provide to facilitate a solution.

Respectfully,

James

I kind of figured nobody would tackle this...|||Looks like a nasty error, and one that should not occur. You could try breaking down the task to try and isolate the cause, as obviously not all scripts do it, so what part of this one does cause the issue. Even if you find it, unless you can change what you are doing it will not fix it, but you may then be able to log a support case with MS giving them more information. You could just log a call now, it does seem like something is very wrong, since the normal task/VSA error handling is not catching this.|||

Thanks for the reply. I will log an incident with MS to resolve this. It's odd because the script task functions properly, I just can't debug this particular task. When the debugger begins, the text displayed is from a totally different script task and a box pops up saying that, "Microsoft Visual Studio has lost the link to your application and will attempt to recover when you logoff."

Respectfully,

James

|||

Hi

I had a similar issue, the details of which can be found below. I believe my issue was around a line of code that assigned a string containing a string of xml directly to a dts string variable:

Dts.Variables("CaseDetail").Value = myNode.OuterXml.ToString()

I removed the above line, copied the script, deleted the script task, added a new script task and then pasted back in the code without the above line. The code then debugged fine but I still needed to save the OuterXml so I assigned it to a string variable first:

Dim outerXML AsString

outerXML = myNode.OuterXml.ToString()

Dts.Variables("CaseDetail").Value = outerXML

This seems to work ok and debugs too. I'm not sure why I couldn't assign directly to the dts variable, but I'm more of a c# man these days, so maybe my VB skills are to blame.

My Error:

Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 28/06/2006
Time: 14:01:16
User: N/A
Computer: ****
Description:
EventType clr20r3, P1 dtattach.exe, P2 9.0.242.0, P3 434f5e26, P4 microsoft.sqlserver.scripttask, P5 9.0.242.0, P6 434f5e02, P7 4f, P8 0, P9 pszqoadhx1u5zahbhohghldgiy4qixhx, P10 NIL.
Data:

|||

Was facing the same issue even after trying all of the above.

Have found workaround for this annoying problem

Everytime you get this error, right click on the problematic project in solution explorer and select 'clean' and then select 'rebuild'

Debugging should then work ok.

ta

arun

|||

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

|||

MohitGupta wrote:

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

If someone replies with an answer please could you mark it as such. This helps when other people are searchig the forums for answers to their own questions.

Thanks

|||

Hello,

I've got the same problem here. Previous week i had no probleme, now i'm not able to put a breakpoint in any of my scripts. This cause a crash... it is very annoying

Version of server 9.0.3153 32 bit

Version of client 9.0.3142 32 bit (last sp2 + hotfixes) - dotnet framework 2.0 + sp2

What change since then : update in windows defender...

I suspect a problem with the antivirus, or windows defender preventing the script from debugging...

Script Task debug error

Good afternoon -

Info:

Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services Client Tools 2005.090.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600

I am trying to debug a script task within a SSIS package by setting a breakpoint within the design window of teh script taks and I get the following error:

EventType : clr20r3 P1 : dtattach.exe P2 : 9.0.242.0 P3 : 434f5e26
P4 : microsoft.sqlserver.scripttask P5 : 9.0.242.0 P6 : 434f5e02
P7 : 4f P8 : 0 P9 : pszqoadhx1u5zahbhohghldgiy4qixhx

Other packages within the solution have script tasks and I can debug these with no problem. This particular script task has constanly given me this error.

Please let me know if there is additional information that I need to provide to facilitate a solution.

Respectfully,

James

I kind of figured nobody would tackle this...|||Looks like a nasty error, and one that should not occur. You could try breaking down the task to try and isolate the cause, as obviously not all scripts do it, so what part of this one does cause the issue. Even if you find it, unless you can change what you are doing it will not fix it, but you may then be able to log a support case with MS giving them more information. You could just log a call now, it does seem like something is very wrong, since the normal task/VSA error handling is not catching this.|||

Thanks for the reply. I will log an incident with MS to resolve this. It's odd because the script task functions properly, I just can't debug this particular task. When the debugger begins, the text displayed is from a totally different script task and a box pops up saying that, "Microsoft Visual Studio has lost the link to your application and will attempt to recover when you logoff."

Respectfully,

James

|||

Hi

I had a similar issue, the details of which can be found below. I believe my issue was around a line of code that assigned a string containing a string of xml directly to a dts string variable:

Dts.Variables("CaseDetail").Value = myNode.OuterXml.ToString()

I removed the above line, copied the script, deleted the script task, added a new script task and then pasted back in the code without the above line. The code then debugged fine but I still needed to save the OuterXml so I assigned it to a string variable first:

Dim outerXML As String

outerXML = myNode.OuterXml.ToString()

Dts.Variables("CaseDetail").Value = outerXML

This seems to work ok and debugs too. I'm not sure why I couldn't assign directly to the dts variable, but I'm more of a c# man these days, so maybe my VB skills are to blame.

My Error:

Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 28/06/2006
Time: 14:01:16
User: N/A
Computer: ****
Description:
EventType clr20r3, P1 dtattach.exe, P2 9.0.242.0, P3 434f5e26, P4 microsoft.sqlserver.scripttask, P5 9.0.242.0, P6 434f5e02, P7 4f, P8 0, P9 pszqoadhx1u5zahbhohghldgiy4qixhx, P10 NIL.
Data:

|||

Was facing the same issue even after trying all of the above.

Have found workaround for this annoying problem

Everytime you get this error, right click on the problematic project in solution explorer and select 'clean' and then select 'rebuild'

Debugging should then work ok.

ta

arun

|||

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

|||

MohitGupta wrote:

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

If someone replies with an answer please could you mark it as such. This helps when other people are searchig the forums for answers to their own questions.

Thanks

|||

Hello,

I've got the same problem here. Previous week i had no probleme, now i'm not able to put a breakpoint in any of my scripts. This cause a crash... it is very annoying

Version of server 9.0.3153 32 bit

Version of client 9.0.3142 32 bit (last sp2 + hotfixes) - dotnet framework 2.0 + sp2

What change since then : update in windows defender...

I suspect a problem with the antivirus, or windows defender preventing the script from debugging...

Script Task debug error

Good afternoon -

Info:

Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services Client Tools 2005.090.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600

I am trying to debug a script task within a SSIS package by setting a breakpoint within the design window of teh script taks and I get the following error:

EventType : clr20r3 P1 : dtattach.exe P2 : 9.0.242.0 P3 : 434f5e26
P4 : microsoft.sqlserver.scripttask P5 : 9.0.242.0 P6 : 434f5e02
P7 : 4f P8 : 0 P9 : pszqoadhx1u5zahbhohghldgiy4qixhx

Other packages within the solution have script tasks and I can debug these with no problem. This particular script task has constanly given me this error.

Please let me know if there is additional information that I need to provide to facilitate a solution.

Respectfully,

James

I kind of figured nobody would tackle this...|||Looks like a nasty error, and one that should not occur. You could try breaking down the task to try and isolate the cause, as obviously not all scripts do it, so what part of this one does cause the issue. Even if you find it, unless you can change what you are doing it will not fix it, but you may then be able to log a support case with MS giving them more information. You could just log a call now, it does seem like something is very wrong, since the normal task/VSA error handling is not catching this.|||

Thanks for the reply. I will log an incident with MS to resolve this. It's odd because the script task functions properly, I just can't debug this particular task. When the debugger begins, the text displayed is from a totally different script task and a box pops up saying that, "Microsoft Visual Studio has lost the link to your application and will attempt to recover when you logoff."

Respectfully,

James

|||

Hi

I had a similar issue, the details of which can be found below. I believe my issue was around a line of code that assigned a string containing a string of xml directly to a dts string variable:

Dts.Variables("CaseDetail").Value = myNode.OuterXml.ToString()

I removed the above line, copied the script, deleted the script task, added a new script task and then pasted back in the code without the above line. The code then debugged fine but I still needed to save the OuterXml so I assigned it to a string variable first:

Dim outerXML As String

outerXML = myNode.OuterXml.ToString()

Dts.Variables("CaseDetail").Value = outerXML

This seems to work ok and debugs too. I'm not sure why I couldn't assign directly to the dts variable, but I'm more of a c# man these days, so maybe my VB skills are to blame.

My Error:

Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 28/06/2006
Time: 14:01:16
User: N/A
Computer: ****
Description:
EventType clr20r3, P1 dtattach.exe, P2 9.0.242.0, P3 434f5e26, P4 microsoft.sqlserver.scripttask, P5 9.0.242.0, P6 434f5e02, P7 4f, P8 0, P9 pszqoadhx1u5zahbhohghldgiy4qixhx, P10 NIL.
Data:

|||

Was facing the same issue even after trying all of the above.

Have found workaround for this annoying problem

Everytime you get this error, right click on the problematic project in solution explorer and select 'clean' and then select 'rebuild'

Debugging should then work ok.

ta

arun

|||

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

|||

MohitGupta wrote:

Thanks Arun,

I tried ur stuff and it worked. I had been having hard time debugging my scripts and used to get this error evrytime.

Thanks again,

Mohit

If someone replies with an answer please could you mark it as such. This helps when other people are searchig the forums for answers to their own questions.

Thanks

|||

Hello,

I've got the same problem here. Previous week i had no probleme, now i'm not able to put a breakpoint in any of my scripts. This cause a crash... it is very annoying

Version of server 9.0.3153 32 bit

Version of client 9.0.3142 32 bit (last sp2 + hotfixes) - dotnet framework 2.0 + sp2

What change since then : update in windows defender...

I suspect a problem with the antivirus, or windows defender preventing the script from debugging...

Script Table with secondary indexes

I used the option "Script Table" --> "Create to" in SQL Server Management Studio Express for a table with secondary index (like IX_IndexName), but in the .sql script file there is only the instruction for the primary key and not for the secondary (I expected something like CREATE INDEX). What can I do?

Hi,

its not within the context menu, you have to do it via the script wizard which can be found by right clicking on the database and choosing to script the database objects. In the next steps you can switch a boolean to create also the indexes within the table.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de
|||

It work fine, very thanks

Monday, March 12, 2012

Script generation for Objects - Management Studio

How do I generate a single script for each object - table, view, index, trigger, sp, function etc.... in SQL Server. The script that is generated from SQL Server wizards is in a single file.

I want to have separate file for each of the objects.

In EM, you right-click on the object, select 'all tasks', then 'Generate SQL Script'. I do not have access to Management Studio right now, so this may or may not be much help.

Do you have access to Enterprise Manager? You can run SQL Server 2000 and 2005 side by side, so it may be worthwhile installing if you cannot do this in MS.

Clarity Consulting (http://www.claritycon.com)

|||

Well we have the same feature in SQL 2005 but I need one individual file for each object. I do not want the script of say all tables in file. I want this in different files with file name as table name that is getting scripted.

It applies to other objects like procs, funcs, triggers, constraints, FKs etc

|||You might look at Scriptio. I use it to create .sql files off of my db schema. On the 2nd tab I select ONE FILE PER OBJECT. www.sqlteam.com. The only problem I have found is that existing sql files (we re-exporting) can't be read-only.|||Currently, the Generate Script Wizard can only create a single file. We plan to implement file-per-object functionality in SP2.

Script generation for Objects - Management Studio

How do I generate a single script for each object - table, view, index, trigger, sp, function etc.... in SQL Server. The script that is generated from SQL Server wizards is in a single file.

I want to have separate file for each of the objects.

In EM, you right-click on the object, select 'all tasks', then 'Generate SQL Script'. I do not have access to Management Studio right now, so this may or may not be much help.

Do you have access to Enterprise Manager? You can run SQL Server 2000 and 2005 side by side, so it may be worthwhile installing if you cannot do this in MS.

Clarity Consulting (http://www.claritycon.com)

|||

Well we have the same feature in SQL 2005 but I need one individual file for each object. I do not want the script of say all tables in file. I want this in different files with file name as table name that is getting scripted.

It applies to other objects like procs, funcs, triggers, constraints, FKs etc

|||You might look at Scriptio. I use it to create .sql files off of my db schema. On the 2nd tab I select ONE FILE PER OBJECT. www.sqlteam.com. The only problem I have found is that existing sql files (we re-exporting) can't be read-only.|||Currently, the Generate Script Wizard can only create a single file. We plan to implement file-per-object functionality in SP2.

Friday, March 9, 2012

script database - create to file

In the management studio there is a function to dump the DDL of a database, script database create to and then I can choose file.

What I was wondering and can't seem to find is, whether it is possible to somehow call this function from a program.

Any language, and connection will do for now, if at all posible, or if there is some other way I haven't found to dump the DDL for a database this woudl be much appreciated.

btw, I'm using a mssql 2005 database.

Regards

Unfortunately, that isn't possible. But here are several ways to approach the issue.

DDL -Script Database to File
http://www.wardyit.com/blog/blog/archive/2006/07/21/133.aspx
http://www.sqlteam.com/publish/scriptio
http://www.aspfaq.com/etiquette.asp?id=5006
http://www.codeproject.com/dotnet/ScriptDatabase.asp
http://www.nigelrivett.net/DMO/DMOScriptAllDatabases.html
http://rac4sql.net/qalite_main.asp

DDL –Script Data to file (Database Publishing Wizard)
http://www.microsoft.com/downloads/details.aspx?FamilyID=29B4FFD8-AC3A-4481-B352-9B185619A901

|||

Hi,

Just to add a thought here - you could use SMO to achieve the task. For instance, SMO exposes a Database object with a Script() method. It is very well documented in the SQL Books Online.

In addition, you could take an easy shortcut - you could use SSIS (the new DTS) and create a scripting task. Then you could simply kick-off the task from your application.

HTH,
Jivko Dobrev - MSFT
--
This posting is provided "AS IS" with no warranties, and confers no rights.

Wednesday, March 7, 2012

Script Component Connection Management

Hello,

Greetings, and Happy Friday. I want to check myself in regards to the proper use of connections in a data flow script component being used as a transformation. I want to ensure that the solution is ideal from a performance standpoint, but more importantly that there won't be any resource leaks from connections that are not being closed or objects that are not being disposed properly.

This transformation script component is writing to a table based on the rows that pass through Input0_ProcessInputRow(). What I'm doing so far is, in the script component script, I've declared a class-level variable of type System.Data.SqlClient.SqlConnection. In the PreExecute() event handler I am initializing this connection with the following code (which comes after the call to MyBase.PreExecute()):

Dim connMgr As IDTSConnectionManager90

connMgr = Me.Connections.JobDB
adoConn = CType(connMgr.AcquireConnection(Nothing), SqlClient.SqlConnection)
If adoConn.State <> ConnectionState.Open Then
adoConn.Open()
End If

connMgr = Nothing

The adoConn variable referred to there is the class-level variable. So, my first questions:

Is this the best way to initialize the connection? And is that code checking adoConn.State necessary? Can I pretty much assume that the connection manager is going to give me an open connection?

Then in the PostExecute() event handler I have this code (again, after the MyBase call):

If Not (adoConn Is Nothing) Then
If adoConn.State = ConnectionState.Open Then
adoConn.Close()
End If
adoConn.Dispose()
adoConn = Nothing
End If

Next questions:

Is this adoConn variable actually holding a reference to an object whose primary owner is in the connection manager? Is it necessary to close my SqlConnection this way, or is that going to actually close the connection manager's connection?

I'm also wondering whether I need to have this same code in the script component's Finalize() handler also...if there's an error I don't want the resource to leak. Or will PostExecute() fire even if there's an error in Input0_ProcessInputRow()?

Thanks in advance,
Dan

Not necessarily in order:

The ADO.NET Connection Manager returns an open connection object. I would rely on it to do its job and assume a problem with the connection manager if by chance you get a connection object that not's open.

I would also rely on the connection manager to do its work afterwards. I suggest that you call ReleaseConnection rather than closing the connection directly.

While it's correct to use PreExecute and PostExecute for things that you only need to do once, you're not taking full advantage of the Integration Services component architecture by (apparently) collapsing a source, a transformation, and a destination into a single component. You may find that all three pieces will be more flexible, and more easily adapted for use elsewhere, if you separate them out. Otherwise, in a sense, you have little more than an ADO.NET application wrapped with the overhead of the SSIS runtime.

The ReleaseConnection method of the connection manager should be taking care of Dispose/Finalize housekeeping.

-Doug

|||

I would also rely on the connection manager to do its work afterwards. I suggest that you call ReleaseConnection rather than closing the connection directly.


Thank you. I will look into ReleaseConnection.

you're not taking full advantage of the Integration Services component architecture by (apparently) collapsing a source, a transformation, and a destination into a single component.


This is a keen observation, and one I'd like to discuss further if you're open
to it. I struggled with finding the best design for this particular situation that fits within the SSIS paradigm and built-in tools. Believe me, if I thought there was a better way than using a script component, I would embrace it, becuase I've been struggling with getting the DataSet caching, managed by PreExecute and PostExecute, to work. If you were to peek into the other parts of my SSIS packages, you would find I think traditional uses of lookups and derivations and unions and destinations.
My situation is that I have a row from a tab-delimited text file flowing through this dataflow that, among 185 other fields, has five fields in it that are not normalized. That is, these five fields each contain a comma-delimited string of value codes. Another way to say it is that these are multi-value fields.
So each mutli-value field must be parsed, and then each sub-value must be looked up in a mapping table. I don't think there's a straightforward way to do that using the built-in transformations.
I can imagine what you might be thinking at this point as an obvious solution, but the kicker is that in advance I will never be able to know how many subvalues any of these five fields could have. There could be anywhere from zero to a dozen for a given row and field. So that makes it tough to use the Derived Column transformation to just parse them and add new columns, because I can't know in advance how many columns will be needed to add.
Furthermore, downstream from that I would not know how many Lookup transformations to create to resolve the values. Perhaps some kind of "Foreach" functionality at the field level within the dataflow would be helpful in a future SSIS version, but in the meantime it seems to me the script component is where it's at.
Thoughts welcome, and thanks again, Doug, for your input on connection management.
Dan
|||

It sounds like what you're really designing is a source (more than a transformation), that needs to parse the multi-valued columns before presenting the data to the Data Flow.

The metadata-driven solution that would be the ideal theoretical solution would be possible using the Integration Services object model, but would require a heck of a lot more lines of code than you now have in your Script component. While lots of users have been asking about self-configuring packages that are driven by run-time metadata, I don't believe I've seen any examples of this yet. Changes in a source ripple all the way downstream through the data flow, so it would not be nearly so simple as just changing (programmatically) the number of output columns coming out of your source.

(As an aside: The IS team took great pains to prevent access from any one component to the package object model and to other components, beyond what was absolutely necessary, like variables and connections. However in Service Pack 1 a means will be provided (IDtsPipelineEnvironmentService) to give custom data flow components programmatic access to the parent data flow task and other objects in it. This would enable a custom solution along the lines of the Load SCD Wizard, which creates transformations etc. as needed...or like a custom source that creates or configures downstream Derived Column and Lookup transformations as needed.)

More clever minds may offer you more clever solutions. :-)

Best wishes,

-Doug

Script automation

Using SQL Server Management Studio, it is easy to create scripts for various
objects such as tables, schemas, login,... My question is: How can I
automate the process ?
I would like to write a kind of batch or script which when executed would
generate the scripts for - let's says - a few schemas and tables.
--
Francois PIETTE
http://www.overbyte.behttp://www.karaszi.com/SQLServer/info_generate_script.asp
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
> Using SQL Server Management Studio, it is easy to create scripts for various objects such as
> tables, schemas, login,... My question is: How can I automate the process ?
> I would like to write a kind of batch or script which when executed would generate the scripts
> for - let's says - a few schemas and tables.
> --
> Francois PIETTE
> http://www.overbyte.be
>|||Give ApexSQL's Script a try. It can script data as well as objects and
comes with a command line interface so you can automate it. Very reasonable
price too.
--
TheSQLGuru
President
Indicium Resources, Inc.
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
> Using SQL Server Management Studio, it is easy to create scripts for
> various objects such as tables, schemas, login,... My question is: How can
> I automate the process ?
> I would like to write a kind of batch or script which when executed would
> generate the scripts for - let's says - a few schemas and tables.
> --
> Francois PIETTE
> http://www.overbyte.be
>|||> http://www.karaszi.com/SQLServer/info_generate_script.asp
Very interesting. I will investigate the various resources mentionned.
Thanks.
--
Francois PIETTE
http://www.overbyte.be
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a écrit
dans le message de
news:542D05DE-A8A3-4877-9D2C-7E9392DEF9B7@.microsoft.com...
> http://www.karaszi.com/SQLServer/info_generate_script.asp
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
> news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
>> Using SQL Server Management Studio, it is easy to create scripts for
>> various objects such as tables, schemas, login,... My question is: How
>> can I automate the process ?
>> I would like to write a kind of batch or script which when executed would
>> generate the scripts for - let's says - a few schemas and tables.
>> --
>> Francois PIETTE
>> http://www.overbyte.be
>|||>> http://www.karaszi.com/SQLServer/info_generate_script.asp
I tryed Microsoft SQL Server Database Publishing Wizard which is mentionned
on the page you referred. It does the job perfectly. It is free, has a GUI
interface and a command line utility. That's just what I needed.
http://www.microsoft.com/downloads/details.aspx?FamilyID=56e5b1c5-bf17-42e0-a410-371a838e570a&DisplayLang=en
Again, thanks.
--
Francois PIETTE
http://www.overbyte.be
"Francois PIETTE" <fpiette@.newsgroups.nospam> a écrit dans le message de
news:%23k$euHLyHHA.5584@.TK2MSFTNGP02.phx.gbl...
>> http://www.karaszi.com/SQLServer/info_generate_script.asp
> Very interesting. I will investigate the various resources mentionned.
> Thanks.
> --
> Francois PIETTE
> http://www.overbyte.be
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a écrit
> dans le message de
> news:542D05DE-A8A3-4877-9D2C-7E9392DEF9B7@.microsoft.com...
>> http://www.karaszi.com/SQLServer/info_generate_script.asp
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
>> news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
>> Using SQL Server Management Studio, it is easy to create scripts for
>> various objects such as tables, schemas, login,... My question is: How
>> can I automate the process ?
>> I would like to write a kind of batch or script which when executed
>> would generate the scripts for - let's says - a few schemas and tables.
>> --
>> Francois PIETTE
>> http://www.overbyte.be
>>
>|||Glad my page helped, and thanks for sharing you findings... :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:eBg$qWLyHHA.600@.TK2MSFTNGP05.phx.gbl...
>> http://www.karaszi.com/SQLServer/info_generate_script.asp
> I tryed Microsoft SQL Server Database Publishing Wizard which is mentionned on the page you
> referred. It does the job perfectly. It is free, has a GUI interface and a command line utility.
> That's just what I needed.
> http://www.microsoft.com/downloads/details.aspx?FamilyID=56e5b1c5-bf17-42e0-a410-371a838e570a&DisplayLang=en
> Again, thanks.
> --
> Francois PIETTE
> http://www.overbyte.be
>
> "Francois PIETTE" <fpiette@.newsgroups.nospam> a écrit dans le message de
> news:%23k$euHLyHHA.5584@.TK2MSFTNGP02.phx.gbl...
>> http://www.karaszi.com/SQLServer/info_generate_script.asp
>> Very interesting. I will investigate the various resources mentionned.
>> Thanks.
>> --
>> Francois PIETTE
>> http://www.overbyte.be
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a écrit dans le message de
>> news:542D05DE-A8A3-4877-9D2C-7E9392DEF9B7@.microsoft.com...
>> http://www.karaszi.com/SQLServer/info_generate_script.asp
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
>> news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
>> Using SQL Server Management Studio, it is easy to create scripts for various objects such as
>> tables, schemas, login,... My question is: How can I automate the process ?
>> I would like to write a kind of batch or script which when executed would generate the scripts
>> for - let's says - a few schemas and tables.
>> --
>> Francois PIETTE
>> http://www.overbyte.be
>>
>

Script automation

Using SQL Server Management Studio, it is easy to create scripts for various
objects such as tables, schemas, login,... My question is: How can I
automate the process ?
I would like to write a kind of batch or script which when executed would
generate the scripts for - let's says - a few schemas and tables.
Francois PIETTE
http://www.overbyte.behttp://www.karaszi.com/SQLServer/in...rate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
> Using SQL Server Management Studio, it is easy to create scripts for vario
us objects such as
> tables, schemas, login,... My question is: How can I automate the process
?
> I would like to write a kind of batch or script which when executed would
generate the scripts
> for - let's says - a few schemas and tables.
> --
> Francois PIETTE
> http://www.overbyte.be
>|||Give ApexSQL's Script a try. It can script data as well as objects and
comes with a command line interface so you can automate it. Very reasonable
price too.
TheSQLGuru
President
Indicium Resources, Inc.
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
> Using SQL Server Management Studio, it is easy to create scripts for
> various objects such as tables, schemas, login,... My question is: How can
> I automate the process ?
> I would like to write a kind of batch or script which when executed would
> generate the scripts for - let's says - a few schemas and tables.
> --
> Francois PIETTE
> http://www.overbyte.be
>|||> http://www.karaszi.com/SQLServer/in...rate_script.asp
Very interesting. I will investigate the various resources mentionned.
Thanks.
--
Francois PIETTE
http://www.overbyte.be
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a crit
dans le message de
news:542D05DE-A8A3-4877-9D2C-7E9392DEF9B7@.microsoft.com...
> http://www.karaszi.com/SQLServer/in...rate_script.asp
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
> news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
>|||>> http://www.karaszi.com/SQLServer/in...rate_script.asp
I tryed Microsoft SQL Server Database Publishing Wizard which is mentionned
on the page you referred. It does the job perfectly. It is free, has a GUI
interface and a command line utility. That's just what I needed.
http://www.microsoft.com/downloads/...&DisplayLang=en
Again, thanks.
--
Francois PIETTE
http://www.overbyte.be
"Francois PIETTE" <fpiette@.newsgroups.nospam> a crit dans le message de
news:%23k$euHLyHHA.5584@.TK2MSFTNGP02.phx.gbl...
> Very interesting. I will investigate the various resources mentionned.
> Thanks.
> --
> Francois PIETTE
> http://www.overbyte.be
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a crit
> dans le message de
> news:542D05DE-A8A3-4877-9D2C-7E9392DEF9B7@.microsoft.com...
>|||Glad my page helped, and thanks for sharing you findings... :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:eBg$qWLyHHA.600@.TK2MSFTNGP05.phx.gbl...
> I tryed Microsoft SQL Server Database Publishing Wizard which is mentionne
d on the page you
> referred. It does the job perfectly. It is free, has a GUI interface and a
command line utility.
> That's just what I needed.
> http://www.microsoft.com/downloads/...&DisplayLang=en
> Again, thanks.
> --
> Francois PIETTE
> http://www.overbyte.be
>
> "Francois PIETTE" <fpiette@.newsgroups.nospam> a crit dans le message de
> news:%23k$euHLyHHA.5584@.TK2MSFTNGP02.phx.gbl...
>

Script automation

Using SQL Server Management Studio, it is easy to create scripts for various
objects such as tables, schemas, login,... My question is: How can I
automate the process ?
I would like to write a kind of batch or script which when executed would
generate the scripts for - let's says - a few schemas and tables.
Francois PIETTE
http://www.overbyte.be
http://www.karaszi.com/SQLServer/info_generate_script.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
> Using SQL Server Management Studio, it is easy to create scripts for various objects such as
> tables, schemas, login,... My question is: How can I automate the process ?
> I would like to write a kind of batch or script which when executed would generate the scripts
> for - let's says - a few schemas and tables.
> --
> Francois PIETTE
> http://www.overbyte.be
>
|||Give ApexSQL's Script a try. It can script data as well as objects and
comes with a command line interface so you can automate it. Very reasonable
price too.
TheSQLGuru
President
Indicium Resources, Inc.
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
> Using SQL Server Management Studio, it is easy to create scripts for
> various objects such as tables, schemas, login,... My question is: How can
> I automate the process ?
> I would like to write a kind of batch or script which when executed would
> generate the scripts for - let's says - a few schemas and tables.
> --
> Francois PIETTE
> http://www.overbyte.be
>
|||> http://www.karaszi.com/SQLServer/info_generate_script.asp
Very interesting. I will investigate the various resources mentionned.
Thanks.
Francois PIETTE
http://www.overbyte.be
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a crit
dans le message de
news:542D05DE-A8A3-4877-9D2C-7E9392DEF9B7@.microsoft.com...
> http://www.karaszi.com/SQLServer/info_generate_script.asp
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
> news:uaBCyiJyHHA.1576@.TK2MSFTNGP03.phx.gbl...
>
|||>> http://www.karaszi.com/SQLServer/info_generate_script.asp
I tryed Microsoft SQL Server Database Publishing Wizard which is mentionned
on the page you referred. It does the job perfectly. It is free, has a GUI
interface and a command line utility. That's just what I needed.
http://www.microsoft.com/downloads/details.aspx?FamilyID=56e5b1c5-bf17-42e0-a410-371a838e570a&DisplayLang=en
Again, thanks.
Francois PIETTE
http://www.overbyte.be
"Francois PIETTE" <fpiette@.newsgroups.nospam> a crit dans le message de
news:%23k$euHLyHHA.5584@.TK2MSFTNGP02.phx.gbl...
> Very interesting. I will investigate the various resources mentionned.
> Thanks.
> --
> Francois PIETTE
> http://www.overbyte.be
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a crit
> dans le message de
> news:542D05DE-A8A3-4877-9D2C-7E9392DEF9B7@.microsoft.com...
>
|||Glad my page helped, and thanks for sharing you findings... :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Francois PIETTE" <fpiette@.newsgroups.nospam> wrote in message
news:eBg$qWLyHHA.600@.TK2MSFTNGP05.phx.gbl...
> I tryed Microsoft SQL Server Database Publishing Wizard which is mentionned on the page you
> referred. It does the job perfectly. It is free, has a GUI interface and a command line utility.
> That's just what I needed.
> http://www.microsoft.com/downloads/details.aspx?FamilyID=56e5b1c5-bf17-42e0-a410-371a838e570a&DisplayLang=en
> Again, thanks.
> --
> Francois PIETTE
> http://www.overbyte.be
>
> "Francois PIETTE" <fpiette@.newsgroups.nospam> a crit dans le message de
> news:%23k$euHLyHHA.5584@.TK2MSFTNGP02.phx.gbl...
>

Saturday, February 25, 2012

Script

I have a foreign key. I want to script how to create it without using
the management studio i.e. from the query analyser in SQL 2005. Is
there a system stored procedure or something that does this for you.
thanks for your help
NewishNo, you will have to build it like
exec ('alter table [' + @.table + '] drop constraint [' + @.constraint + ']')
from..
Read up this article
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/e960df1a-13fc-43ee-ba91-34c1b719ac2c.htm
"Newish" <ahussain3@.gmail.com> wrote in message
news:1175352912.176014.48640@.q75g2000hsh.googlegroups.com...
>I have a foreign key. I want to script how to create it without using
> the management studio i.e. from the query analyser in SQL 2005. Is
> there a system stored procedure or something that does this for you.
> thanks for your help
> Newish
>|||Here's an example from BOL:
USE AdventureWorks ;
GO
CREATE TABLE Person.ContactBackup
(ContactID int) ;
GO
ALTER TABLE Person.ContactBackup
ADD CONSTRAINT FK_ContactBacup_Contact FOREIGN KEY (ContactID)
REFERENCES Person.Contact (ContactID) ;
ALTER TABLE Person.ContactBackup
DROP CONSTRAINT FK_ContactBacup_Contact ;
GO
DROP TABLE Person.ContactBackup ;
If you want to get the syntax 'for free' you can create the FK in EM and
rather than actually save the change, simply take a look at the script that
is generated. Cheers, Paul Ibison SQL Server MVP,
www.replicationanswers.com

Script

I have a foreign key. I want to script how to create it without using
the management studio i.e. from the query analyser in SQL 2005. Is
there a system stored procedure or something that does this for you.
thanks for your help
NewishNo, you will have to build it like
exec ('alter table [' + @.table + '] drop constraint [' + @.constraint
+ ']')
from..
Read up this article
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/e960df1a-13fc-43ee-ba91-
34c1b719ac2c.htm
"Newish" <ahussain3@.gmail.com> wrote in message
news:1175352912.176014.48640@.q75g2000hsh.googlegroups.com...
>I have a foreign key. I want to script how to create it without using
> the management studio i.e. from the query analyser in SQL 2005. Is
> there a system stored procedure or something that does this for you.
> thanks for your help
> Newish
>|||Here's an example from BOL:
USE AdventureWorks ;
GO
CREATE TABLE Person.ContactBackup
(ContactID int) ;
GO
ALTER TABLE Person.ContactBackup
ADD CONSTRAINT FK_ContactBacup_Contact FOREIGN KEY (ContactID)
REFERENCES Person.Contact (ContactID) ;
ALTER TABLE Person.ContactBackup
DROP CONSTRAINT FK_ContactBacup_Contact ;
GO
DROP TABLE Person.ContactBackup ;
If you want to get the syntax 'for free' you can create the FK in EM and
rather than actually save the change, simply take a look at the script that
is generated. Cheers, Paul Ibison SQL Server MVP,
www.replicationanswers.com

Script

I have a foreign key. I want to script how to create it without using
the management studio i.e. from the query analyser in SQL 2005. Is
there a system stored procedure or something that does this for you.
thanks for your help
Newish
No, you will have to build it like
exec ('alter table [' + @.table + '] drop constraint [' + @.constraint + ']')
from..
Read up this article
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/e960df1a-13fc-43ee-ba91-34c1b719ac2c.htm
"Newish" <ahussain3@.gmail.com> wrote in message
news:1175352912.176014.48640@.q75g2000hsh.googlegro ups.com...
>I have a foreign key. I want to script how to create it without using
> the management studio i.e. from the query analyser in SQL 2005. Is
> there a system stored procedure or something that does this for you.
> thanks for your help
> Newish
>