Showing posts with label attempting. Show all posts
Showing posts with label attempting. Show all posts

Tuesday, March 27, 2012

Calling Stored Procedure from an ActiveX task

I'm attempting to call a storedprocedure from within an ActiveX task in
a DTS and am getting a "Command Text was not set for the command
object" error. I have no problem if I replace the stored procedure call
with the actual SQL.

Is it possible to directly call a SP via an ActiveX task? If yes, could
somebody help me with the syntax please?

This is what I have currently have

Set Conn = CreateObject("ADODB.Connection")
SQL = "exec (MySP)"
set RLoop=conn.Execute(SQL)

do while (NOT RLoop.EOF)
msgbox RLoop(1)
RLoop.MoveNext

Loop

TIA

KarthikKarthik (karthiksmiles@.gmail.com) writes:
> I'm attempting to call a storedprocedure from within an ActiveX task in
> a DTS and am getting a "Command Text was not set for the command
> object" error. I have no problem if I replace the stored procedure call
> with the actual SQL.
> Is it possible to directly call a SP via an ActiveX task? If yes, could
> somebody help me with the syntax please?
> This is what I have currently have
> Set Conn = CreateObject("ADODB.Connection")
> SQL = "exec (MySP)"
> set RLoop=conn.Execute(SQL)

Cmd = CreateObject("ADODB.Command")
Cmd.ActiveConnection = Conn
Cmd.CommandType = adStoredProcedure
Cmd.CommandText = "MySP"
Set rs = cmd.Execute

Not that I have ever done it in DTS, but this should be like ADO anywhere
else.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Tuesday, February 14, 2012

calculating percents in a group header

I am attempting to calculate a percent value in a group header of a report.
My formula looks somethig like:
Iif(sum(Fields.empgolamt.Value,â'table1_Group2â') <> 0,
sum(Fields!empamt.Value,â'table1_Group2â') /
sum(Fields!empgolamt,â'table_Group2â'), 0)
but this results in a divide by zero error. Is there some way to perform
this calculation in a group header or footer (it gives the same error in the
footer).I noticed in your code you are using different datasets to check for
zero and for doing the actual computation. You check the zero condition
in table1_Group2 and then you the denominator comes from table_Group
(without the "1" suffixing "table"). This might be your problem.|||This is just a typo (can't copy and paste from the the expressions window).
The data set referenced in the expression in the report is consistent - there
is only one table in the report.
"Bob" wrote:
> I noticed in your code you are using different datasets to check for
> zero and for doing the actual computation. You check the zero condition
> in table1_Group2 and then you the denominator comes from table_Group
> (without the "1" suffixing "table"). This might be your problem.
>|||There have been many related threads about "division by zero" in this
newsgroup. Please check e.g.:
*
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=3dc7d0e0-d962-47ab-a832-6127ffa45a37&sloc=en-us
*
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=c688a5d9-684a-4d54-970a-56a0cb5e7a8d&sloc=en-us
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"reportwriter" <reportwriter@.discussions.microsoft.com> wrote in message
news:C7D4367C-F704-4ACC-95D5-5922DCDEFD1E@.microsoft.com...
>I am attempting to calculate a percent value in a group header of a report.
> My formula looks somethig like:
> Iif(sum(Fields.empgolamt.Value,"table1_Group2") <> 0,
> sum(Fields!empamt.Value,"table1_Group2") /
> sum(Fields!empgolamt,"table_Group2"), 0)
> but this results in a divide by zero error. Is there some way to perform
> this calculation in a group header or footer (it gives the same error in
> the
> footer).
>

Sunday, February 12, 2012

Calculating Age...

Hello..
I am attempting to write a T-SQL script that will calculate a person's age
based on a date in the DOB field. The DOB field is a smalldatetime. I want
to return this calculated field in a result set. So for example, if the
date in the DOB field is 01/01/1900... I want the age to be returned as 105
(2005 - 1900). I am using SQL Server 2000
Any help would be appreciated...
Thanks,
Bretthttp://www.aspfaq.com/2233
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Brett Davis" <bdavis123@.cox.net> wrote in message
news:OTREukdQFHA.2932@.TK2MSFTNGP09.phx.gbl...
> Hello..
> I am attempting to write a T-SQL script that will calculate a person's age
> based on a date in the DOB field. The DOB field is a smalldatetime. I
> want to return this calculated field in a result set. So for example, if
> the date in the DOB field is 01/01/1900... I want the age to be returned
> as 105 (2005 - 1900). I am using SQL Server 2000
> Any help would be appreciated...
> Thanks,
> Brett
>
>|||So say that this date is the birth date:
DROP FUNCTION TIMEMEMORIAL
GO
CREATE FUNCTION TIMEMEMORIAL
(
@.BIRTHDATE smalldatetime,
@.CURRENTDATE smalldatetime
)
RETURNS VARCHAR(200)
AS
BEGIN
DECLARE @.CURRENTYEAR CHAR(4)
DECLARE @.BIRTHYEAR CHAR(4)
DECLARE @.Result varchar(200)
SET @.BIRTHYEAR = CAST(YEAR(@.BIRTHDATE) as Char(4))
SET @.CURRENTYEAR = CAST(YEAR(@.CURRENTDATE) as Char(4))
Select @.result = CAST(datediff(yy,@.BIRTHDATE,@.CURRENTDATE
) AS varchar(10)) +
' (' + @.BIRTHYEAR + ' - ' + @.CURRENTYEAR + ')'
RETURN @.Result
END
Select dbo.TimeMemorial('20000101',getdate())
HTH, Jens Smeyer
http://www.sqlserver2005.de
--
"Brett Davis" <bdavis123@.cox.net> schrieb im Newsbeitrag
news:OTREukdQFHA.2932@.TK2MSFTNGP09.phx.gbl...
> Hello..
> I am attempting to write a T-SQL script that will calculate a person's age
> based on a date in the DOB field. The DOB field is a smalldatetime. I
> want to return this calculated field in a result set. So for example, if
> the date in the DOB field is 01/01/1900... I want the age to be returned
> as 105 (2005 - 1900). I am using SQL Server 2000
> Any help would be appreciated...
> Thanks,
> Brett
>
>|||See :
http://groups.google.ca/groups?selm...FTNGP09.phx.gbl
Anith|||I think this is easier;
checking for VALID data...
Making assumption that your want it from TODAY
select
case
when ISDATE(convert(char(15),[DATEFIELD])) = 0 then null
else
datediff(year, convert(datetime,([DATEFIELD])),getdate(
))
end
"Brett Davis" wrote:

> Hello..
> I am attempting to write a T-SQL script that will calculate a person's age
> based on a date in the DOB field. The DOB field is a smalldatetime. I wa
nt
> to return this calculated field in a result set. So for example, if the
> date in the DOB field is 01/01/1900... I want the age to be returned as 10
5
> (2005 - 1900). I am using SQL Server 2000
> Any help would be appreciated...
> Thanks,
> Brett
>
>
>|||On Fri, 15 Apr 2005 10:29:04 -0700, Jim Yurt wrote:

>I think this is easier;
>checking for VALID data...
>Making assumption that your want it from TODAY
>select
>case
>when ISDATE(convert(char(15),[DATEFIELD])) = 0 then null
>else
>datediff(year, convert(datetime,([DATEFIELD])),getdate(
))
>
>end
Hi Jim,
But that will return the number of year boundaries (dec 31 / Jan 1)
since the birth date, not the age!
SELECT DATEDIFF(year, '20041231', '20050101'),
DATEDIFF(year, '20040101', '20051231')
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Try This:
If @.DOB is datetime date of birth, and
@.CurDT is a dateTime with current date, then
Select Year(@.CurDT) - Year(@.DOB) -
Case When Month(@.CurDT) < Month(@.DOB) Then 1
When Month(@.CurDT) > Month(@.DOB) Then 0
When Day(@.CurDT) < Day(@.DOB) Then 1
Else 0 End
"Brett Davis" wrote:

> Hello..
> I am attempting to write a T-SQL script that will calculate a person's age
> based on a date in the DOB field. The DOB field is a smalldatetime. I wa
nt
> to return this calculated field in a result set. So for example, if the
> date in the DOB field is 01/01/1900... I want the age to be returned as 10
5
> (2005 - 1900). I am using SQL Server 2000
> Any help would be appreciated...
> Thanks,
> Brett
>
>
>