Call A SP From Another SP
Jun 23, 2008
MS SQL 2005
I developed several SP that update tables
If I execute them one by one in the SQL Sever Management Studio, they work ok
Now,
I want to execute them all inside another SP
I wrote it (attached code)
Execute it and give me a message that runs successfully but that is not true
May anyone of You tell me the right syntax to do it?
[Code]
USE REPORTES
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATEPROCEDURE dbo.Astral_sp_Acumula
AS
--
EXECUTE [REPORTES].[dbo].[Astral_sp_AcCpasArtC]
GO
EXECUTE [REPORTES].[dbo].[Astral_sp_AcDevArtC]
GO
EXECUTE [REPORTES].[dbo].[Astral_sp_AcVtasArtV]
GO
-- More sp executions
[Code]
Thanks
JG
View 2 Replies
ADVERTISEMENT
Mar 19, 2008
Hi,
I am producing a php report using SQL queries to show the SLA status of our calls. Each call has response, fix & completion targets. If any of these targets are breached, the whole SLA status is set as 'Breach'.
The results table should look like the one below:
CallRef.
Description
Severity
ProblemRef
Logged
Date
Call
Status
SLA Status
C0001
Approval for PO€™s not received
2
DGE0014
05-01-06 14:48
Resolved
Breach
C0002
PO€™s not published
2
DGE0014
06-01-06 10:21
Resolved
OK
C0003
Approval for PO€™s not received from Siebel.
2
n/a
05-01-06 14:48
Investigating
OK
Whereas I can pick the results for the first 6 columns from my Select query, the 'SLA Status' column requires the following calculation:
if (due_date < completed_date)
{ sla_status = 'OK';
}
else sla_status = 'Breach';
The Select statement in my query is looking like this...
Select Distinct CallRef, Description, Severity, ProblemRef, Logdate, Status, Due_date, Completed_date;
The problem is that my query is returning multiple entries for each stage of the call (see below), whereas I just want one entry for each call, with SLA status 'Breach' if any of the stages for the call were out of SLA.
CallRef.
Description
Severity
ProblemRef
Logged
Date
Call
Status
SLA Status
C0001
Approval for PO€™s not received
2
DGE0014
05-01-06 14:48
Resolved
Breach
C0001
Approval for PO€™s not received
2
DGE0014
05-01-06 14:48
Resolved
OK
C0001
Approval for PO€™s not received
2
DGE0014
05-01-06 14:48
Resolved
Breach
Any help will be much much appreciated, this issue has been bothering me for some time now!!!
View 7 Replies
View Related
Jan 8, 2008
I've written a T-SQL stored procedure that I want to call other stored procedures. The opening part of it looks like this:set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[spArchive] @dtArchiveBefore DateTimeASEXEC spArchiveAHD @dtArchiveBeforeGOEXEC spArchiveContract_History @dtArchiveBeforeGOEXEC spArchiveContracts @dtArchiveBeforeGO But I'm getting this error repeatedly: Msg 137, Level 15, State 2, Line 2 Must declare the scalar variable "@dtArchiveBefore".I've searched for this term but can't figure out what's wrong with my code.Any ideas?Robert W.
View 4 Replies
View Related
Aug 27, 2001
Hi, There,
Do you know when should I use extend sp to call a dll file, and when should I use sp_OACreate to call dll. It seems only dll created by C++ can be called from extend sp, how about VB created dll?
Thank you very much
Tony
View 1 Replies
View Related
Apr 3, 2006
i have made a .sql file in which i want to call another .sql file
plz tell me the syntax for it
View 5 Replies
View Related
Sep 21, 2006
Hi all,
I have 2 tables like that
CREATE TABLE tab1 (
id int IDENTITY (1, 1) NOT NULL ,
master varchar (50) NULL
) ON PRIMARY
GO
CREATE TABLE tab2 (
id int IDENTITY (1, 1) NOT NULL ,
student_name varchar (50) NULL ,
master_id int NULL
)
Now i want to create a Sp
which is
create proc inner_sp(@s1 varchar(50))
as
insert into tab1(master) values (@s1)
and i want to call it from another sp
create proc outer_sp2(@s2 varchar(50),@s1 varchar(50))
as
declare @r int
exec inner_sp @s1
set @r=Scope_Identity()
insert into tab2(student_name,master_id) values(@s2,@r)
exec outer_sp2 'Vivek1','Test'
But in table tab2 master_id column contain NULL value....
Please fix it...
Ujjwal
View 5 Replies
View Related
Jun 27, 2006
is it possible to call a SQL job from an ASP.NET application? if so, how? I'm using VS.net2003 and am programming in C#I've been searching for a while, but haven't found anything. It doesn't help that one of my keywords when searching is "job(s)."
View 1 Replies
View Related
Sep 14, 2006
I have two databases with two identical tables in seperate physical locations. I want database B tables to be updated automatically when database A tables change. Is there a way to call a web service from SQL to make this happen? Or is there a better way to do this? I would really like it to get the rows that were modified and then copy only those rows to the other database tables. If anyone knows if this can be done please let me know. Thank you.
View 4 Replies
View Related
Dec 18, 2003
Well I seem to be a gomer when trying to understand XML. Could some one please help me? I am trying to write a script or DTS package that will read 4 XML files (Do not call list) compare each phone number to the numbers I have in my DB and if there is a match put the contactID in to another table. Or at the very least get the XML phone numbers into the database. This is what the XML doc looks like
- <list type="full" level="state" val="AL">
- <ac val="205">
<ph val="2025896" />
<ph val="2061994" />
<ph val="2061995" />
<ph val="2062028" />
View 3 Replies
View Related
Apr 16, 2005
can someone point me in the right direction? I know how to call a stored procedure, but I can't seem to find code examples on how to call user defined functions.
View 2 Replies
View Related
Jan 4, 2000
Hi SQL Colleagues:
Is it possible for me to call a DTS package from within a stored procedure? If it is not possible to do so directly, would I at least be able to call the package through a job?
Thanks!!!
Don
View 1 Replies
View Related
Aug 23, 2000
Hello,
Somebody in my society has realised a function logwrite in a DLL logfil32.dll
With Sybase we can use it without problem.
It write in a file for example 'c:logmetrixloglogmetrix.txt' the text 'test logwrite'
I add logwrite in the extended stored procedures of mzster
and i tried to do :
execute master..logwrite 'c:logmetrixloglogmetrix.txt','test logwrite'
In the file logmetrix.txt 'test logwrite' wasn't be added. WHY??
Thanks to tour answers
Axel
View 2 Replies
View Related
Oct 2, 2006
Hi,
I need to call a stored procdure from a SQL statement that I am running from query analyzer.
My SQL statement will select from a master table of bills. I have a stored procedure that calculates the amount due on each bill. The sp does not use the master table in the calculation.
How do I form the SQL statement to call the sp, which needs one of the master table columns as a parm?
i.e.
SELECT *, EXEC sp_abc columns name AS whatever
FROM tblMaster WHERE......
TIA!
Dave
View 3 Replies
View Related
Feb 6, 2007
Hello,
How do you call 2 columns from a table? mine wont work?
Quote: select message, id_by, id_from, name from message, members where message.id_by = message.id_by
output is ( I can't get the names );
Quote: message / by / to
“hello” / mark / jen
“hi” / shane / bill
message table; Quote:
message | by | to
“hello” | 1 | 3
“hi” | 2 | 4
members table; Quote:
id | name
1 | mark
2 | shane
3 | jen
4 | bill
View 1 Replies
View Related
Jul 18, 2006
hi, if i have query like following
select * from o_customer,o_address
where
o_customer.name = o_address.custname
is it same as
select * from o_customer
inner join o_address on o_customer.name = o_address.custname
if there are same, which one is prefer in term of performance ..
thank you for guidance
View 2 Replies
View Related
Dec 1, 2006
Hi, sorry I am kind of stuck how to do this correctly.
The following is my problem statement:
There are three tables: TAB1 TAB2 TAB3
There is a 1 to many relationship between TAB2 and TAB1.
For every row in TAB2 that has a match in TAB1, they are related via
TAB2.col3 = TAB1.col2
I want to delete all those rows in both tables that match, but I have to
delete those rows in TAB1 first because of dependency constraints.
The primary key for TAB2.col1
Therefore I need to have a select block first and store it somewhere(?)
select
TAB2.col1
from
TAB2
where
TAB2.col3 IN
(select
TAB1.col2
from
TAB1
where
TAB1.col1 IN
(select
TAB3.col1
from
TAB3))
Then I delete all those rows in TAB1 that has a match in TAB3
delete from TAB1
where
TAB1.col1 IN
(select
TAB3.col1
from
TAB3))
now i delete those rows in TAB2 from the result set of the first sql block.
thanks for any help.
View 6 Replies
View Related
Apr 30, 2008
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 4/30/2008 2:25:41 PM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ostat_CDS_rpt47_2006]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[ostat_CDS_rpt47_2006]
GO
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 23/04/2008 11:26:14 ******/
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 22/04/2008 14:35:33 ******/
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 21/04/2008 11:46:08 ******/
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 16/04/2008 17:18:04 ******/
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 04/04/2008 12:44:34 ******/
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 31/03/2008 12:03:31 ******/
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 31/03/2008 11:11:07 ******/
/****** Object: Stored Procedure dbo.ostat_CDS_rpt47_2006 Script Date: 09/03/2008 14:31:30 ******/
-- ostat_CDS_rpt47_2006 2008,03,17,17
CREATE procedure ostat_CDS_rpt47_2006
@pYear int,
@pMonth int,
@pDay1 int,
@pDay2 int
as
begin
declare @sql varchar(4000)
declare @tb1 varchar(128)
declare @tb2 varchar(128)
set @tb1= 'margin..ncds0421'
set @tb2='Report.dbo.ob_apr08'
set @sql=
'
insert into '+@tb2+'
select yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,0 isCallback,
cast(callcost as decimal (10,5)) cost,count(*) attempt,
sum(case when connectflg=1 then 1 else 0 end) connected,sum(talktime) Talktime
from '+@tb1+'
where yyyy='+ltrim(str(@pYear))+'
and mm='+ltrim(Str(@pMonth)) +'
and dd between '+ltrim(Str(@pDay1))+' and '+ltrim(Str(@pDay2))+'
and talktime >0 and trunkin is null
group by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5))
order by yyyy,mm,dd,HH,sitecode,TrunkOut,SwitchCode,prefixCode,cast(callcost as decimal (10,5))
'
--print (@sql)
exec (@sql)
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
View 2 Replies
View Related
Mar 28, 2006
can i make a function call from stored procedure
View 3 Replies
View Related
Dec 13, 2007
Question:
what do we call the table that does the n to n Relation
Hi,
When we have Table1 and Table2, then we link both tables using a third table Table3 that relates n records in Table1 to n records in table2, how do we call Table3? There is a name in dataBase modeling for that, right?
View 8 Replies
View Related
Feb 16, 2008
With regular .net web services in vb.net I can expose the service and call it like this:
http://server/EnrollmentLookup/EnrollmentService.asmx/GetS3MonitorLogs?StartDate=02/02/08&EndDate=02/05/08
But when I create a SQL XML Webservice via an endpoint all I can find on the net is how to show the wsdl.
http://localhost/Contacts?wsdl
Ive created a method in the "Contacts" webservice called GetContacts. Why cant I construct a similar url to execute that method without having to write a vb.net wrapper for it?
View 6 Replies
View Related
Aug 16, 2006
Hi All,
Is it possible to call methods of C++ COM ATL component from C# SSIS component?
I did try to call methods of C++ COM ATL component and C# library inside my SSIS but without success :-(
Regards,
Svilen Varbanov
View 3 Replies
View Related
May 9, 2006
Hi
I have created a SSIS package with an FTP call. I have it set to EncryptSensitiveWithPassword.
I can manually run the package from my IDE. Once I build it, create a job, it fails.
If you try to run the package directly from the Stored Packages in Integrations Services it fails with the following error:
Error: The task "FTP Call" cannot run on this edition of Integration Services. It requires a higher level edition.
This is running on our production with a full version.
Does anyone have any suggestions?ideas?
Any incite would be greatly appreciated.
PR
View 4 Replies
View Related
Feb 27, 2008
Hello,
Does anybody know if it's possible to call an object (specifically, a textbox) from the expression of another object? I would imagine it would something like 'objectname.Value' or 'objectname.ToString', but I can't get it to recognise my object names.
I have two textboxes - Last Event and Number of Weeks Since Last Event. I have an expression to calculate the date of the last event (which is rather lengthy), and currently I get the number of weeks by doing a DateDiff between Today and another copy of the lengthy LastEvent code. This works, but it would be much simpler and more efficient if I could just say:
DateDiff("W", LastEvent.ToString, Today)
Anybody have any ideas?
Cheers,
Peter
View 3 Replies
View Related
Feb 26, 2008
Does anybody knows how to call a function from one VB source file to another VB source file??
I have create a MDI parent form, now i want to call the function of the child form from the parent form. Does anyone know this??
View 1 Replies
View Related
Jan 15, 2008
Dear All,
I would like to use SP as Subquery in my query. SP returns decimal value..
Is it possible, if not do you have an idea ?
Code Blockselect id, (exec css_satis_puan2 @ay1='10.2007',@ay2='11.2007',@ay3='12.2007',@tip2=1,@servis=ss.id) as result1, (exec css_satis_puan2 @ay1='10.2007',@ay2='11.2007',@ay3='12.2007',@tip2=2,@servis=ss.id) as result2
from users as ss where uid between 1 and 200
Thanks in advance,
Regards
Cuneyt
View 4 Replies
View Related
Oct 18, 2007
We have an application that use SQL server 2005 . The databses on the server are mirrored. Also we have witness. During a test we failovered from principal to mirrored server. Our application gets error message during 5 minutes. The errors were that sql connection has timeout.
Also on mirrored server in event viewer I found next errors:
An SNI call failed during a Service Broker/Database Mirroring transport operation. SNI error '10065(error not found)'.
You can find this error in sys.message, where message_id=8471
An error occurred in a Service Broker/Database Mirroring transport connection endpoint, Error: 8471, State: 2. (Near endpoint role: Initiator, far endpoint address: '10.10.23.8')
The mirroring connection to "TCP://primary_srv:5022" has timed out for database "Application_database" after 10 seconds without a response. Check the service and network connections.
Database mirroring connection error 2 'Connection attempt failed with error: '10060(error not found)'.' for 'TCP://primary_srv:5022'.
Database mirroring connection error 4 '64(error not found)' for 'TCP://primary_srv.posprod.supersol.co.il:5022'.
last 2 errors can be found in sys.message, where message_id=1474Our computers is windows 2003, SQL2005 sp2 with fotfix of audust. Also few ours before this test .Net3 was installed on those computers.
Any advises? Some help & ideas. What does this errors means?
View 2 Replies
View Related
Mar 19, 2007
I am trying to create a stored procedure to Call ALTER LOGIN based on the the username passed in. However, the Alter login statement chokes on any parameter. Is there a way I can alter sql logins from a web form ?
I try the following and it bombs
ALTER LOGIN @LoginName WITH PASSWORD = @Password
But this works
ALTER LOGIN 'TestUser' WITH PASSWORD = '123test'
I guess the alter login statement does not work with Parameters.
Any thoughts ?
View 4 Replies
View Related
Aug 1, 2007
I have a stored procedure that creates a normalized table from an existing denorm table. So I just need a simple way to call this SP from an aspx page. It would be good though to know how many records were effected, but this is not a requirement.
View 5 Replies
View Related
Aug 29, 2007
I have a stored procedure I created in SQL server 2005. Now I need to call the stored procedure in C#. Can someone help me out here? What is the C# code I need to call this stored procedure? I have never done this before and need some help.
CREATE PROCEDURE [dbo].[MarketCreate]
( @MarketCode nvarchar(20), @MarketName nvarchar(100), @LastUpdateDate nvarchar(2),)
ASINSERT INTO Market( MarketCode MarketName LastUpdateDate)VALUES( @MarketCode @MarketName @LastUpdateDate
)
View 5 Replies
View Related
Dec 13, 2007
When we have Table1 and Table2, then we
link both tables using a third table Table3 that relates n records in
Table1 to n records in table2, how do we call Table3? There is a name
in dataBase modeling for that, right?
View 1 Replies
View Related
Feb 25, 2008
Can someone help me to understand a stored procedure I am learning about? At line 12 below, the code is calling a function named"ttg_sfGroupsByPartyId" I ran the function manually and it returns several rows/records from the query. So I am wondering? does a call to the function return a temporary table? And if so, is the temporary table named PartyId? If so, the logic seems strange to me because earlier they are using the name PartyId as a variable name that is passed in.
1 ALTER PROCEDURE [dbo].[GetPortalSettings]2 (3 @PartyId uniqueidentifier,45 AS6 SET NOCOUNT ON7 CREATE TABLE #Groups8 (PartyId uniqueidentifier)910 /* Cache list of groups user belongs in */11 INSERT INTO #Groups (PartyId)12 SELECT PartyId FROM ttg_sfGroupsByPartyId(@PartyId)
View 4 Replies
View Related
Apr 2, 2008
I try to run the storeprocedure to get retRandomCode.Value, but it returns no value.
Using myConnection2 As New SqlConnection(connString)
myConnection2.Open()
Dim myPuzzleCmd2 As New SqlCommand("GetRandomCode", myConnection2)
myPuzzleCmd2.CommandType = CommandType.StoredProcedure
Dim retLengthParam As New SqlParameter("@Length", SqlDbType.TinyInt, 6)
retLengthParam.Direction = ParameterDirection.Input
myPuzzleCmd2.Parameters.Add(retLengthParam)
Dim retRandomCode As New SqlParameter("@RandomCode", SqlDbType.VarChar, 30)
retRandomCode.Direction = ParameterDirection.Output
myPuzzleCmd2.Parameters.Add(retRandomCode)
Try
Dim reader2 As SqlDataReader = myPuzzleCmd2.ExecuteReader()
myPuzzleCmd2.ExecuteNonQuery()Catch ex As Exception
Response.Write("sp value : " & retRandomCode.Value) <----- no value
Dim iRandomCode(1) As StringReDim Preserve iRandomCode(1)
iRandomCode(1) = Convert.ToString(retRandomCode.Value)Session.Remove("RandomCode")
HttpContext.Current.Session("RandomCode") = iRandomCode
myPuzzleCmd2 = Nothing
Finally
myConnection2.Close()
End Try
End Using
View 10 Replies
View Related