Showing posts with label thru. Show all posts
Showing posts with label thru. 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

How to get thru security of Sql server http endpoint?

I have write the coding to create http endpoint in the sql server 2005, but if i type my pc ownself ip address (ex, 192.168.0.110) to connect to the sql server http endpoint, it prompt me for Username and Password. I didn't set any username and password before, what should i type ? Or what should i do to pass thru this authentication?

Thanks in advance.

Cheers,

Winson

Hi Winson,

For security reasons, the SQL Server 2005 http endpoints for Native XML Web Services require the client application to send user credentials. By default, the user account who created the HTTP endpoint will have access to connect to the endpoint. Users of the sysadmin role will also have access to the endpoint. All other SQL login accounts, must be granted explicit connect permissions. Please refer to Books Online's (BOL) GRANT Endpoint permission topic available at http://msdn2.microsoft.com/en-us/library/ms187811.aspx for additional information. For information regarding how to specify user credentials in the client application in .Net Frameworks, please refer to the following BOL topic http://msdn2.microsoft.com/en-us/library/ms175929.aspx.

Jimmy

|||

Hello Jimmy,

Thanks for the help, actually the situation is like this. I using nusoap (php) to connect to the Sql server http endpoint. but i fail to pass thru the security of sql sever http endpoint over the Internet. What do you think? Do you have any idea regarding this this of connection? nusoap (php) <> sql server http endpoint?

Thanks in advanced.

Cheers,

Winson

How to get the Windows login name?

How to get the Windows login name inside SQL Server 2005 when the SQL Server
2005 is accessed thru terminal service? Cannot use .Net.Additional Information:
SQL Server 2005 is connected using SQL Authentication.
"Peter" wrote:

> How to get the Windows login name inside SQL Server 2005 when the SQL Serv
er
> 2005 is accessed thru terminal service? Cannot use .Net.|||You can't. SQL Server only knows the user as the SQL login.
-Sue
On Thu, 8 Mar 2007 16:52:03 -0800, Peter
<Peter@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Additional Information:
>SQL Server 2005 is connected using SQL Authentication.
>
>
>"Peter" wrote:
>|||Peter,
What client protocol are you using?
Chris
"Peter" <Peter@.discussions.microsoft.com> wrote in message
news:6442C4B1-5DC4-41F9-BCA6-410A3D95F50B@.microsoft.com...[vbcol=seagreen]
> Additional Information:
> SQL Server 2005 is connected using SQL Authentication.
>
>
> "Peter" wrote:
>

Monday, March 26, 2012

How to get the name of the database currently connected to?

I have an application which connects to a sql server database thru a SQL
Server ODBC driver. In the application, I have a database componenet with
its aliasname name set to the name of the ODBC driver. I have several
databses on the server and I need to know if I can get the actual name of
the database I am connecting to?Sam,
Try:
SELECT DB_NAME()
HTH
Jerry
"Sam" <Sam@.discussions.microsoft.com> wrote in message
news:F29D0818-2376-432D-B8AE-F8A734A8199F@.microsoft.com...
>I have an application which connects to a sql server database thru a SQL
> Server ODBC driver. In the application, I have a database componenet
> with
> its aliasname name set to the name of the ODBC driver. I have several
> databses on the server and I need to know if I can get the actual name of
> the database I am connecting to?|||SELECT DB_NAME()
David Portas
SQL Server MVP
--
"Sam" <Sam@.discussions.microsoft.com> wrote in message
news:F29D0818-2376-432D-B8AE-F8A734A8199F@.microsoft.com...
>I have an application which connects to a sql server database thru a SQL
> Server ODBC driver. In the application, I have a database componenet
> with
> its aliasname name set to the name of the ODBC driver. I have several
> databses on the server and I need to know if I can get the actual name of
> the database I am connecting to?|||Try:
select db_name()
go
AMB
"Sam" wrote:

> I have an application which connects to a sql server database thru a SQL
> Server ODBC driver. In the application, I have a database componenet wit
h
> its aliasname name set to the name of the ODBC driver. I have several
> databses on the server and I need to know if I can get the actual name of
> the database I am connecting to?|||Thanks :)
"David Portas" wrote:

> SELECT DB_NAME()
> --
> David Portas
> SQL Server MVP
> --
> "Sam" <Sam@.discussions.microsoft.com> wrote in message
> news:F29D0818-2376-432D-B8AE-F8A734A8199F@.microsoft.com...
>
>

Friday, March 9, 2012

How to Get previous record thru sql query

How to Get previous record thru sql query

For the example

my table:

1 usera item1 1.00 01/02/07
2 usera item1 2.00 02/02/07
3 userc item2 3.00 03/02/07

--
how to use the query to make them join became like this (get/join with the next record)


1 usera item1 1.00 01/02/07 item1 2.00 02/02/07
3 userc item2 3.00 03/02/07 null null null

>.<
need help ... thanks alot

You can try something like :

select m1.*, m2.Item, m2.Qty, m2.Date from mytable m1 LEFT JOIN mytable m2 ON m1.user=m2.user WHERE m1.date != m2.Date

Hope this helps,

Vivek

|||

it will work only if dates are different change it to (assuming that your first column is Identity ID)

select m1.*, m2.Item, m2.Qty, m2.Date from mytable m1 LEFT JOIN mytable m2 ON m1.user=m2.user WHERE m1.ID != m2.ID

to get data in all cases, but this will return only two sets of data per customer what if you have more records per customer?

And it will also repeat entries for your test data you will have records for users reported two times in different order 1 with 2 and 2 with 1

so you have to modify this query a little

select m1.*, m2.Item, m2.Qty, m2.Date
from mytable m1
LEFT JOIN mytable m2
ON m1.user=m2.user
andm1.ID != m2.ID
WHEREm1.ID < m2.ID

but it will work only if you have no more than 2 records per user

try and let me know if it works fro you or not.

Thanks

|||

Thanks alot who has replied me ^^

Yes.. i hav try on the way thatJpazgier provided, but it's too bad i m having more than 2 records in same user and the order is not just only at the top and bottom for example it may

1 usera item1 1.00 01/02/07
2 usera item1 2.00 02/02/07
3 userc item2 3.00 03/02/07
4 usera item1 1.50 04/02/07

and after i have join it will become

1 usera item1 1.00 01/02/07 item1 2.00 02/02/07
2 usera item1 2.00 02/0207 item1 1.50 04/02/07
3 userc item2 3.00 03/02/07 null null null
4 usera item1 1.50 04/02/07 null null null

thank u very much for ans my question ^^

|||

Another query for getting two consecutive rows (the row which you want along with the previous row)

select * from TableName Where DateField='02/03/07' Or DateField in(Select Top 1 DateField from TableName where DateField < ''02/03/07' Order by DateField DESC)

Thanks

SadSorry Webmaster: (I am feeling bad that The forum @. ASP.Net was not allowed me to enter my Indian Standard Time (GMT + 5:30))

Wednesday, March 7, 2012

how to get only weekdays

Using SS2000, in QA I want to return data for only days Monday thru Friday.
Is there a way to do this? Is there some function that will give me only the
weekdays?
Thanks,
Dan D.
Dan,
Check http://www.aspfaq.com/show.asp?id=2519.
Dejan Sarka, SQL Server MVP
Mentor
www.SolidQualityLearning.com
"Dan D." <DanD@.discussions.microsoft.com> wrote in message
news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Using SS2000, in QA I want to return data for only days Monday thru
> Friday.
> Is there a way to do this? Is there some function that will give me only
> the
> weekdays?
> Thanks,
> --
> Dan D.
|||Thanks Dejan. I'll take a look at that.
Dan D.
"Dejan Sarka" wrote:

> Dan,
> Check http://www.aspfaq.com/show.asp?id=2519.
> --
> Dejan Sarka, SQL Server MVP
> Mentor
> www.SolidQualityLearning.com
> "Dan D." <DanD@.discussions.microsoft.com> wrote in message
> news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
>
>
|||You could use the DAY function to extract the numeric day of the week
select DAY(getdate())
This would give you all Sundays, for example.
SELECT * FROM Table1 where DAY(YourDateField) = 1
If you need to account for holidays or other more complex date calculations
the calendar table is the way to go.
"Dan D." <DanD@.discussions.microsoft.com> wrote in message
news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Using SS2000, in QA I want to return data for only days Monday thru
Friday.
> Is there a way to do this? Is there some function that will give me only
the
> weekdays?
> Thanks,
> --
> Dan D.
|||SELECT * FROM Table1 where DATEPART(dw, YourDateField) between 2 and 6
http://sqlservercode.blogspot.com/
|||I discovered that function. I also discovered datepart which is what I'm
using. Thanks Terri.
Dan D.
"Terri" wrote:

> You could use the DAY function to extract the numeric day of the week
> select DAY(getdate())
> This would give you all Sundays, for example.
> SELECT * FROM Table1 where DAY(YourDateField) = 1
> If you need to account for holidays or other more complex date calculations
> the calendar table is the way to go.
> "Dan D." <DanD@.discussions.microsoft.com> wrote in message
> news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Friday.
> the
>
>
|||I came across datepart after some more looking. It works. Thanks SQL.
Dan D.
"SQL" wrote:

> SELECT * FROM Table1 where DATEPART(dw, YourDateField) between 2 and 6
> http://sqlservercode.blogspot.com/
>

how to get only weekdays

Using SS2000, in QA I want to return data for only days Monday thru Friday.
Is there a way to do this? Is there some function that will give me only the
weekdays?
Thanks,
--
Dan D.Dan,
Check http://www.aspfaq.com/show.asp?id=2519.
Dejan Sarka, SQL Server MVP
Mentor
www.SolidQualityLearning.com
"Dan D." <DanD@.discussions.microsoft.com> wrote in message
news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Using SS2000, in QA I want to return data for only days Monday thru
> Friday.
> Is there a way to do this? Is there some function that will give me only
> the
> weekdays?
> Thanks,
> --
> Dan D.|||Thanks Dejan. I'll take a look at that.
--
Dan D.
"Dejan Sarka" wrote:

> Dan,
> Check http://www.aspfaq.com/show.asp?id=2519.
> --
> Dejan Sarka, SQL Server MVP
> Mentor
> www.SolidQualityLearning.com
> "Dan D." <DanD@.discussions.microsoft.com> wrote in message
> news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
>
>|||You could use the DAY function to extract the numeric day of the week
select DAY(getdate())
This would give you all Sundays, for example.
SELECT * FROM Table1 where DAY(YourDateField) = 1
If you need to account for holidays or other more complex date calculations
the calendar table is the way to go.
"Dan D." <DanD@.discussions.microsoft.com> wrote in message
news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Using SS2000, in QA I want to return data for only days Monday thru
Friday.
> Is there a way to do this? Is there some function that will give me only
the
> weekdays?
> Thanks,
> --
> Dan D.|||SELECT * FROM Table1 where DATEPART(dw, YourDateField) between 2 and 6
http://sqlservercode.blogspot.com/|||I discovered that function. I also discovered datepart which is what I'm
using. Thanks Terri.
--
Dan D.
"Terri" wrote:

> You could use the DAY function to extract the numeric day of the week
> select DAY(getdate())
> This would give you all Sundays, for example.
> SELECT * FROM Table1 where DAY(YourDateField) = 1
> If you need to account for holidays or other more complex date calculation
s
> the calendar table is the way to go.
> "Dan D." <DanD@.discussions.microsoft.com> wrote in message
> news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Friday.
> the
>
>|||I came across datepart after some more looking. It works. Thanks SQL.
--
Dan D.
"SQL" wrote:

> SELECT * FROM Table1 where DATEPART(dw, YourDateField) between 2 and 6
> http://sqlservercode.blogspot.com/
>

how to get only weekdays

Using SS2000, in QA I want to return data for only days Monday thru Friday.
Is there a way to do this? Is there some function that will give me only the
weekdays?
Thanks,
--
Dan D.Dan,
Check http://www.aspfaq.com/show.asp?id=2519.
--
Dejan Sarka, SQL Server MVP
Mentor
www.SolidQualityLearning.com
"Dan D." <DanD@.discussions.microsoft.com> wrote in message
news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Using SS2000, in QA I want to return data for only days Monday thru
> Friday.
> Is there a way to do this? Is there some function that will give me only
> the
> weekdays?
> Thanks,
> --
> Dan D.|||Thanks Dejan. I'll take a look at that.
--
Dan D.
"Dejan Sarka" wrote:
> Dan,
> Check http://www.aspfaq.com/show.asp?id=2519.
> --
> Dejan Sarka, SQL Server MVP
> Mentor
> www.SolidQualityLearning.com
> "Dan D." <DanD@.discussions.microsoft.com> wrote in message
> news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> > Using SS2000, in QA I want to return data for only days Monday thru
> > Friday.
> > Is there a way to do this? Is there some function that will give me only
> > the
> > weekdays?
> >
> > Thanks,
> > --
> > Dan D.
>
>|||You could use the DAY function to extract the numeric day of the week
select DAY(getdate())
This would give you all Sundays, for example.
SELECT * FROM Table1 where DAY(YourDateField) = 1
If you need to account for holidays or other more complex date calculations
the calendar table is the way to go.
"Dan D." <DanD@.discussions.microsoft.com> wrote in message
news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> Using SS2000, in QA I want to return data for only days Monday thru
Friday.
> Is there a way to do this? Is there some function that will give me only
the
> weekdays?
> Thanks,
> --
> Dan D.|||SELECT * FROM Table1 where DATEPART(dw, YourDateField) between 2 and 6
http://sqlservercode.blogspot.com/|||I discovered that function. I also discovered datepart which is what I'm
using. Thanks Terri.
--
Dan D.
"Terri" wrote:
> You could use the DAY function to extract the numeric day of the week
> select DAY(getdate())
> This would give you all Sundays, for example.
> SELECT * FROM Table1 where DAY(YourDateField) = 1
> If you need to account for holidays or other more complex date calculations
> the calendar table is the way to go.
> "Dan D." <DanD@.discussions.microsoft.com> wrote in message
> news:B7E42041-0ADA-4AFA-8512-8EF4806E33DC@.microsoft.com...
> > Using SS2000, in QA I want to return data for only days Monday thru
> Friday.
> > Is there a way to do this? Is there some function that will give me only
> the
> > weekdays?
> >
> > Thanks,
> > --
> > Dan D.
>
>|||I came across datepart after some more looking. It works. Thanks SQL.
--
Dan D.
"SQL" wrote:
> SELECT * FROM Table1 where DATEPART(dw, YourDateField) between 2 and 6
> http://sqlservercode.blogspot.com/
>