hello sir,
Please help, it is urgent Please help, it is urgent
I am using query string to call stored procedure as shown below in VBA of EXCEL
Private Sub Workbook_Open()
On Error GoTo errorhand
Dim objMyQueryTable As QueryTable
Set objMyQueryTable = ActiveSheet.QueryTables.Add (Connection:="OLEDB;Provider=SQLOLEDB;Data Source=robot; Initial Catalog
=CallDemo;User ID=sa;Password=sa", Destination:=ActiveSheet.Range("A1"))
objMyQueryTable.CommandText = "report"
objMyQueryTable.CommandType = xlCmdSql
objMyQueryTable.Name = "icici"
objMyQueryTable.Refresh True
errorhand:
MsgBox Err.Description
end sub
----------------------------------------
* "report" is the name of stored procedure for in sql server.
This report has following statements
-------------------------------------------
alter procedure report
As
SET NOCOUNT ON
IF OBJECT_ID('tempdb.dbo.##temptable') IS NOT NULL
delete from ##temptable
else
create table ##temptable(Dates int)
IF OBJECT_ID('tempdb.dbo.##finalreport') IS NOT NULL
delete from ##finalreport
else
create table ##finalreport(Number nvarchar(25),Dates int,CallerId nvarchar(25),CallDuration int,FailureReason nvarchar(50),CallStatus nvarchar(25))
Insert into ##temptable(Dates)
Select distinct DateTimeStamp from CallLog where DateTimeStamp between 1111493635 and 1111493853 order by DateTimeStamp
declare datecursor cursor for select Dates from ##temptable
open datecursor
declare @Dates int
fetch next from datecursor into @Dates
while @@fetch_status = 0
begin
select @dates
Select CallReferenceNumber,DateTimeStamp,CallerID,CallDuration,Reason,callstatus from CallLog where callstatus='Success' and DateTimeStamp=@Dates
Select CallReferenceNumber,DateTimeStamp,CallerID,CallDuration,Reason,callstatus from CallLog where callstatus='Failure' and DateTimeStamp=@Dates
fetch next from datecursor into @Dates
end
close datecursor
deallocate datecursor
-------------------------------------------------------
* it is giving result of only first select statement and not giving the result of second select statement in excel.
* My friend told 1 query string accepts only only select statement, is it true. if so how to make only one querestring to execute multiple select statements.
Please help, it is urgent
------------------
Bookmarks