Showing posts with label local. Show all posts
Showing posts with label local. Show all posts

Friday, March 30, 2012

how to get total number of variables using scripttask

I want to loop thru all the variables in my package and set number of variables that had variable-name begin w/LOCAL, so I can use the name to generate a dynamic SQL query for the next EXEC SQL Task. any one know how to do this.

Use the count property on the variables collection.|||

that is what I did, Dts.Varaiables.count, but it did not return the right numbers. I have over 10 variables and it return 1.

|||

Have you added your 10+ variables to either the ReadOnlyVariables or ReadWriteVariables list? The Dts.Variables collection is generated based on those preset list of variables.

Thanks,
Patrik

|||

no, I did not.

OK, let me back out a little bit, I try to use the event handler as a trigger for my custom audit logging, for each task when I am done, I want to use a script to find out what is in my variables pool, loop thru them and build a query, (“select count(*) from ‘[“ + @.variable1), and then the next execute SQL task will execute this and return the count to a variable so I can have the OnPostExecute event write out the record counts, so I only have 1 variable “MySQL” in the ReadWriteVariables list, since what I want is when I create a new package, all I have to do is to add or remove local variables, no code changes is need it. if I have to put in all the variables, then I defeat my intention, is there a work around for this? Any suggestion is greatly appreciated.

|||

What sort of processing are you trying to achieve with the Script Task? Which variables are you using and looking for in the loop? Is the collection of variables you're interested in always the same? If you don't fill in the ReadOnlyVariables and ReadWriteVariables properties you can do the work using the VariableDispenser (http://msdn2.microsoft.com/de-de/library/microsoft.sqlserver.dts.runtime.variabledispenser.aspx); however, you would still need to know the name of the variables you're interested in reading.

If you're using the Script Task just to create a SQL command statement for the Execute SQL Task you could look at using expressions (http://msdn2.microsoft.com/en-us/library/ms141214.aspx).

Cheers,
Patrik

|||

Hi..

You can read all variables by using ActiveX Script Task instead of using Script Task.

Function Main()
Dim oVal

Dim isSystem, varType, varName
Dim str
MSGBOX "Total Variable = " & DTSGlobalVariables.Count

For each oVal in DTSGlobalVariables
isSystem = oVal.SystemVariable
varType = oVal.DataType
varName = oVal.QualifiedName

MSGBOX varName & " / " & varType & " / " & "System:" & isSystem

Next
Main = DTSTaskExecResult_Success

End Function

HTH

ADConsulting / SQLLeader.com / Daeseong Han

Wednesday, March 28, 2012

how to get the server name ?

Hi,
will the SERVERPROPERTY('machine name') property
give you the name of the SERVER on the local machine?
So that I can feed it into a connection statement such as
Data Source="...name..."? Because I tried using
Data Source=(local) and it doesn't seem to work -- any
reason why?
Thanks!
Christy Warner.
"Chris V." wrote:

> SERVEProperty is exactly what I was needed 1
> Thanks for your help.
> Chris
> "Chris V." <tophe_news@.hotmail.com> wrote in message
> news:emzzoXu$EHA.2180@.TK2MSFTNGP12.phx.gbl...
>
>ChristyWarner wrote:
> Hi,
> will the SERVERPROPERTY('machine name') property
> give you the name of the SERVER on the local machine?
> So that I can feed it into a connection statement such as
> Data Source="...name..."? Because I tried using
> Data Source=(local) and it doesn't seem to work -- any
> reason why?
> Thanks!
> Christy Warner.
>
If you're already connected, then I don't understand why you need the
server name. OTOH, if you're not connected, then you can't use the
SERVERPROPERTY function because you need to be connected...
If SQL Server is installed locally and is the default instance, you can
use "(local)" as the server name, use "." as the server name, use the IP
Address as the server name, or use the name of the PC on which SQL
Server is installed as the server name.
Where is this SQL Server? If local, what is the name of your PC? If
remote, someone at the company should be able to tell you what the SQL
Server name is.
David Gugick
Imceda Software
www.imceda.com|||did you try 'localhost'
VikasKumar
---
VikasKumar's Profile: http://www.msmcse.ms/member.php?userid=769
View this thread: http://www.msmcse.ms/t-1870132190

Friday, March 9, 2012

How to get publisher name , publication name and publish database?

Hi All:
i want to write a winform to search publisher name , publication
name and publish database from local sql sever dynamicly.(C#),
So anyone can give some hints of what's method or function to get
publisher name , publication name and publish database from local sql sever?
Thanks
nick
Check out "Introducing Replication Programming", "Replication Object", and
"Samples" in Books online.
Donna
"nick" wrote:

> Hi All:
> i want to write a winform to search publisher name , publication
> name and publish database from local sql sever dynamicly.(C#),
> So anyone can give some hints of what's method or function to get
> publisher name , publication name and publish database from local sql sever?
>
> Thanks
> nick
>
>