|
Hi There,
I tried changing it to a Stored procedure but still have a problem
ALTER PROCEDURE [dbo].[sp_LiveRevenueGraph]
-- Add the parameters for the stored procedure here
@ShowType NVARCHAR(20),
@Statistic NVARCHAR(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @data TABLE ([Week] NVARCHAR(120), Sunday DECIMAL(12,5), Monday DECIMAL(12,5), Tuesday DECIMAL(12,5), Wednesday DECIMAL(12,5),
Thursday DECIMAL(12,5), Friday DECIMAL(12,5), Saturday DECIMAL(12,5), SubTotal DECIMAL(12,5))
-- Insert statements for procedure here
-- INSERT INTO @data EXECUTE C_WEB_sp_RevenueAchievedByShow 0, @ShowType;
END
Error : --INSERT EXEC statement cannot be nested
Please advice.
Thanks
|
|
|
|
|
|
Thanks very much for your help.
I have changed it to the following But seems to have problem with My server Name when using Open Query
Declare @ServName nvarchar(50)
set @ServName= (select @@SERVERNAME)
select @ServName
SELECT * INTO #data FROM OPENQUERY(@ServName, 'EXEc C_WEB_sp_RevenueAchievedByShow 0, @ShowType')
Error : Msg 102, Level 15, State 1, Procedure sp_LiveRevenueGraph, Line 22
Incorrect syntax near '@ServName
|
|
|
|
|
There is no possible way for me to debug that. I have no access to your database, no knowledge of what you're doing. I think you need to spend some time debugging your problem yourself.
|
|
|
|
|
Hi,
Just tried it, the code below works for me on the AdventureWorks database;
sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
SELECT *
INTO #MyTempTable
FROM OPENROWSET(
'SQLNCLI',
'Server=(local);Trusted_Connection=yes;',
'EXEC AdventureWorks.dbo.uspGetEmployeeManagers 1'
) Hope this helps
I are Troll
|
|
|
|
|
Many thanks for your help.
I have the following Error :
Msg 7403, Level 16, State 1, Line 2
The OLE DB provider "PC-NAME\SqlDev" has not been registered.
Here is how i changed it on my Development :
sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
SELECT *
INTO #MyTempTable
FROM OPENROWSET(
'Kibrom\SqlDev',
'Server=(local);Trusted_Connection=yes;',
'Exec [dbo].[C_WEB_sp_RevenueAchievedByShow] 1,2'
)
|
|
|
|
|
Nice
--edit
The first argument should be a provider; the name of the server has already been provided as "(local)" - this gets replaced with "Kibrom\SqlDev". Something like below should work;
SELECT *
INTO #MyTempTable
FROM OPENROWSET(
'SQLNCLI',
'Server=(local);Trusted_Connection=yes;',
'Exec [dbo].[C_WEB_sp_RevenueAchievedByShow] 1,2'
)
I are Troll
modified on Friday, June 4, 2010 2:35 PM
|
|
|
|
|
Hi
Please check my this query and tell me error
select productname,sum(issueqty) QTY from issuance
where issuedate >= '5/1/2010' and issuedate <= '5/31/2010'
and productid= '777' and productid= '778'
group by productname
order by productname
i want to show these two product total issue qty of month may
|
|
|
|
|
mjawadkhatri wrote: i want to show these two product total issue qty of month may
For all records with the number "777" and "778"? Didn't you want an OR instead of an AND ?
I are Troll
|
|
|
|
|
yes all record of productid=777 and productid=778
|
|
|
|
|
You want the records that have number "777" or "778". You are asking for the records that have *both* numbers.
The resulting list will have records with both records containing 777 AND 778, but you'll need to ask for the records that contain 777 OR 778
I are Troll
|
|
|
|
|
In high school, to drive home the difference between 'AND' and 'OR' in a logical statement, the teacher asked all of the students in room 201 and 202 to please stand up.
When people stood, he asked if there body was split, thereby allowing them to be in two rooms at the same time.
|
|
|
|
|
and that is when the class decided to tear down the wall between rooms 201 and 202 I presume.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Not to be picky here but wouldn't that just merge the 2 rooms into 1 room and therefor they once again weren't in 201 AND 202 but only in 201 OR 202 (or another number given to the now twice as big a room )
|
|
|
|
|
Of course not. Without the wall, they would be in both rooms at the same time. Unless you insist on renumbering everything, or otherwise denormalize the school.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Well if you keep the numbering that would mean 201 is one half of the room and 202 another half of the room.
One could argue that in order to be in both rooms at the same time you would have to be standing in the exact middle of the room (where the wall was).
I don't know why but I'm in a picky mood today, must be because of the slow day at work
|
|
|
|
|
Tom Deketelaere wrote: I don't know why but I'm in a picky mood today
The example shows that picky is what's being trained - since the devil is always in the details
I are Troll
|
|
|
|
|
Try this one...
select productname,sum(issueqty) QTY from issuance
where issuedate >= '5/1/2010' and issuedate <= '5/31/2010'
and productid in ('777' ,'778')
group by productname
order by productname
|
|
|
|
|
|
Actually he shouldn't use that type of date format since it can fail.
Better is to use the SQL standard: yyyyMMdd
select productname,sum(issueqty) QTY from issuance
where issuedate >= '20100501' and issuedate <= '20100531'
and productid in ('777' ,'778')
group by productname
order by productname
|
|
|
|
|
Tom Deketelaere wrote: that type of date format since it can fail.
Can you elaborate? What would allow or cause it to fail?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
In the UK, the date '5/31/2010' would fail if you localize the database because we format dates as dd/mm/yyyy. Using yyyymmdd format or explicitly using CONVERT is much safer.
|
|
|
|
|
I guess that falls under the DAH!! category. Obviously if you are using dates they must be in the correct format Using universal time will ensure these issues do not arise.
'20100501' is just as likely to be mistyped and cause issues.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
At a guess, regional settings:
5/1/2010 can be interpreted as 01-May-2010 or 05-Jan-2010
The second date, 5/31/2010, is presumed to mean '31-May-2010' and provides context for the first date.
I encounter this issue on a regular basis; especially when 'constructing' datetime stamps on the fly.
For example, our mill production day starts at 7:00 AM.
For for month to date information for a given date, I have to build the date as:
'01-' (month of given date) '-' (year of given date).
Hope that helps.
Tim
|
|
|
|
|
The implication I read was the OP said it would fail because of SQL server issue. Of course you must use the proper date format. That's user error not a SQL Server issue
I know the language. I've read a book. - _Madmatt
|
|
|
|