Wednesday, March 28, 2012
Having problems getting stored procedure to work.
call it, I get 0 rows returned. I call it like so:
EXEC RetrieveShipments 'City','Is','Omaha'
or
EXEC RetrieveShipments 'City','Contains','Omaha'
neither method returns any rows. Each field in the database is defined as
char(255).
There are numerous rows in the database where City is Omaha.
Any help is appreciated.
----
--
ALTER PROCEDURE [dbo].[RetrieveShipments]
@.ColumnName varchar(32),
@.Expr varchar(16),
@.Data varchar(64)
AS
BEGIN
SET NOCOUNT ON;
IF @.Expr = 'Is' BEGIN
SELECT *
FROM Shipped
WHERE @.ColumnName = @.Data
END
IF @.Expr = 'Contains' BEGIN
SELECT *
FROM Shipped
WHERE @.ColumnName LIKE '%'+@.Data
OR @.ColumnName LIKE '%'+@.Data+'%'
OR @.ColumnName LIKE @.Data+'%'
END
ENDYou can't pick a column name dynamically like that. Please read these
articles:
http://www.sommarskog.se/dyn-search.html
http://www.sommarskog.se/dynamic_sql.html
"Terry Olsen" <tolsen64@.hotmail.com> wrote in message
news:ODCTtz2RGHA.4792@.TK2MSFTNGP14.phx.gbl...
> I'm having trouble getting the following stored procedure to work. When I
> call it, I get 0 rows returned. I call it like so:
> EXEC RetrieveShipments 'City','Is','Omaha'
> or
> EXEC RetrieveShipments 'City','Contains','Omaha'
> neither method returns any rows. Each field in the database is defined as
> char(255).
> There are numerous rows in the database where City is Omaha.
> Any help is appreciated.
> ----
--
> ALTER PROCEDURE [dbo].[RetrieveShipments]
> @.ColumnName varchar(32),
> @.Expr varchar(16),
> @.Data varchar(64)
> AS
> BEGIN
> SET NOCOUNT ON;
> IF @.Expr = 'Is' BEGIN
> SELECT *
> FROM Shipped
> WHERE @.ColumnName = @.Data
> END
> IF @.Expr = 'Contains' BEGIN
> SELECT *
> FROM Shipped
> WHERE @.ColumnName LIKE '%'+@.Data
> OR @.ColumnName LIKE '%'+@.Data+'%'
> OR @.ColumnName LIKE @.Data+'%'
> END
> END
>
>|||Okay, after perusing through the articles (I printed them out for in-depth
reading later), I came up with this and it works. I'd like some input on
whether this is "good form" and "safe code". I'd like to see how it could
be done better if you have examples. Thanks.
ALTER PROCEDURE [dbo].[RetrieveShipments]
@.ColumnName char(255),
@.Expr char(255),
@.Data char(255)
AS
SET NOCOUNT ON;
DECLARE @.sql varchar(4000)
IF @.Expr = 'Is' BEGIN
SELECT @.sql = 'SELECT * FROM Shipped WHERE ' + @.ColumnName + ' = ''' + @.Data
+ ''''
END
IF @.Expr = 'Contains' BEGIN
SELECT @.sql = 'SELECT * FROM Shipped WHERE (' +
@.ColumnName + ' LIKE ' + '''%' + @.data + ''') OR (' +
@.ColumnName + ' LIKE ' + '''%' + @.data + '%'') OR (' +
@.ColumnName + ' LIKE ' + '''' + @.data + '%'')'
END
EXEC(@.sql)
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:O1SUt42RGHA.4920@.tk2msftngp13.phx.gbl...
> You can't pick a column name dynamically like that. Please read these
> articles:
> http://www.sommarskog.se/dyn-search.html
> http://www.sommarskog.se/dynamic_sql.html|||On Tue, 14 Mar 2006 20:36:40 -0700, Terry Olsen wrote:
>Okay, after perusing through the articles (I printed them out for in-depth
>reading later), I came up with this and it works. I'd like some input on
>whether this is "good form" and "safe code".
Hi Terry,
Not at all.
Change this line
EXEC(@.sql)
to
PRINT @.sql
Then execute your procedure with these arguments:
EXEC [dbo].[RetrieveShipments]
@.ColumnName = '1 = 2; DROP TABLE Shipped; --',
@.Expr = 'Is',
@.Data = 'Irrelevant'
and imagine what would have happened if you had not changed the EXEC to
PRINT.
Other errors are the use of char instead of varchar (scroll the output
of the previous exercise to the right to see the rest of the query -
probably not what you intended either) and the unneeded use of three
LIKE expressions: % matches _ZERO_ or more characters, so you can just
use
LIKE '%Anything%'
instead of
LIKE '%Anything%' OR LIKE '%Anything' OR LIKE 'Anything%'
> I'd like to see how it could
>be done better if you have examples.
See the print-out that you've already made of:
http://www.sommarskog.se/dyn-search.html
Hugo Kornelis, SQL Server MVP|||You can do it, one of the things that you need to ensure that you do however
is give your user(s) Select permissions for the target table if your
security exposure permits you to do so...
Example based on your original...
--
alter PROCEDURE [dbo].[RetrieveShipments]
@.ColumnName varchar(32),
@.Expr varchar(16),
@.Data varchar(64)
AS
declare @.dothis nvarchar (2000)
BEGIN
SET NOCOUNT ON;
IF @.Expr = 'Is' BEGIN
select @.dothis = ' SELECT * FROM Shipped WHERE ' + @.ColumnName + ' = ' +
@.Data
END
IF @.Expr = 'Contains' BEGIN
select @.dothis = ' SELECT * FROM Shipped WHERE ' + @.ColumnName + ' LIKE %' +
@.Data + ' OR ' + @.ColumnName + ' LIKE %' + @.Data + '% OR ' + @.ColumnName + '
LIKE ' + @.Data + '%'
END
END
execute(@.dothis)
--
Alice
========================================
=================
please respond to the newsgroups so that everyone can see the answers!
========================================
=================
"Terry Olsen" <tolsen64@.hotmail.com> wrote in message
news:ODCTtz2RGHA.4792@.TK2MSFTNGP14.phx.gbl...
> I'm having trouble getting the following stored procedure to work. When I
> call it, I get 0 rows returned. I call it like so:
> EXEC RetrieveShipments 'City','Is','Omaha'
> or
> EXEC RetrieveShipments 'City','Contains','Omaha'
> neither method returns any rows. Each field in the database is defined as
> char(255).
> There are numerous rows in the database where City is Omaha.
> Any help is appreciated.
> ----
--
> ALTER PROCEDURE [dbo].[RetrieveShipments]
> @.ColumnName varchar(32),
> @.Expr varchar(16),
> @.Data varchar(64)
> AS
> BEGIN
> SET NOCOUNT ON;
> IF @.Expr = 'Is' BEGIN
> SELECT *
> FROM Shipped
> WHERE @.ColumnName = @.Data
> END
> IF @.Expr = 'Contains' BEGIN
> SELECT *
> FROM Shipped
> WHERE @.ColumnName LIKE '%'+@.Data
> OR @.ColumnName LIKE '%'+@.Data+'%'
> OR @.ColumnName LIKE @.Data+'%'
> END
> END
>
>
Having problems deploying a report.
I am working with a MS 2005 SQL Server database. I have the following error message. A connection could not be made to the report server http://localhost/ReportServer. I am trying to develop these on a network server. Is this a configuration issue, that it is expecting this on the local machine.
Thanks!
Terry B
Hi,
are you sure that the user (which deploy the report) have access rights to the report server. You can administrate this under http://localhost/reports and then under security, there you must add the AD-user.
I hope this help.
|||When I go on the internet and type in Http://localhost I receive a not found error message. It claims to be Under Construction and references the IIS Help. But other reports from the server do deploy and I cannot see them from either machine
Thanks!
Terry
|||Hi,
when localhost the SQL-Reporting-Server is, you must take the url http://localhost/Reports! It is importen to give the subweb Reports to go to the administrationwebsite of the reporting server...
Having problem with sql create
Analyser:
CREATE TABLE tblxyz as (Select * from tblPlayers);
tblPlayers has 2 rows in it.
I continue to get the error
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'.
I have tried it with and without the () and it works on Oracle but not
SQL/2K. Don't know why.
This has all developed because of another problem.
First I have select with a complex join all records with a certain
employee ID.
Then I have to select the top 20 (by date) records from the first
select.
From the second select results I have to select the top 10 by a
numeric field.
The only way I thought of doing it was to create temporary tables (see
original question).SELECT * INTO tblxyz FROM tblPlayers
if you want an empty table with only the schema of tblPlayers use a WHERE
1=0
"Jim R" <JimReid@.comcast.net> wrote in message
news:7eb6df4b.0407150949.15a9468c@.posting.google.c om...
> The following is a create that I was trying to run in SQL/2000 SQL
> Analyser:
> CREATE TABLE tblxyz as (Select * from tblPlayers);
> tblPlayers has 2 rows in it.
> I continue to get the error
> Server: Msg 156, Level 15, State 1, Line 1
> Incorrect syntax near the keyword 'AS'.
> I have tried it with and without the () and it works on Oracle but not
> SQL/2K. Don't know why.
> This has all developed because of another problem.
> First I have select with a complex join all records with a certain
> employee ID.
> Then I have to select the top 20 (by date) records from the first
> select.
> From the second select results I have to select the top 10 by a
> numeric field.
> The only way I thought of doing it was to create temporary tables (see
> original question).|||> CREATE TABLE tblxyz as (Select * from tblPlayers);
The SQL Server equivalent is
SELECT * INTO tblxyz FROM tblPlayers ;
> The only way I thought of doing it was to create temporary tables (see
> original question).
Without more of a spec (DDL for the tables, some INSERT statements of sample
data) it's impossible for us to know if that's really the best way to
achieve what you want.
--
David Portas
SQL Server MVP
--|||Thank you. That works great. Now I create tbltemp and from tbltemp I
create a tbltempa and then drop tbltemp. All in a stored procedure.
Then after I'm done with my selection of the recordset I'll drop the
tbltempa.
Thanks again.
Jim
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||SQL is a declarative language. To get the most out of SQL, start by writing
a query that will produce the end result you require rather than thinking of
procedural solutions like [Query 1] -> [Temp Table] -> [Query 2] -> etc.
From your description I doubt that temp tables are the most concise,
efficient or maintainable solution to your problem.
--
David Portas
SQL Server MVP
--|||David,
You are right. My problem was that I didn't know how to create a select
within a select. What I ended up with was just that and it is all in a
single stored procedure with no temporary tables. Works really well.
My biggest problem was all new things I was trying to do. I have always
done simple select statements before both with Views and Stored
Procedures.
Then I discovered that I needed to feed parameters to the first select
which knocked out Views. Then I needed only the top 20 by date and from
the top 20 the lowest 10(numerically) of those top 20.
It got very confusing real fast when I had a stored procedure that
select via param for the top 20. It would pick the top 20 first and
then the parms. Which wasn't the sequence I wanted.
Since I was only running on SQL/2k I ended up with the following stored
procedure:
CREATE PROCEDURE [SelectUSGA1]]
@.PlayerID integer
AS
SELECT TOP 10 WITH TIES dbo.tblScores.[Date], dbo.tblScores.Player,
dbo.tblScores.HandiDiff, dbo.tblScores.Tees, dbo.tblScores.H1,
dbo.tblScores.H2, dbo.tblScores.H3, dbo.tblScores.Course,
dbo.tblCourse.CourseID, dbo.tblCourse.CourseName, dbo.tblCourse.Hole1,
dbo.tblCourse.Hole2, dbo.tblCourse.Hole3, dbo.tblCourse.Hole4,
dbo.tblCourse.Hole5, dbo.tblCourse.Hole6, dbo.tblCourse.Hole7,
dbo.tblCourse.Hole8, dbo.tblCourse.Hole9, dbo.tblCourse.Hole10,
dbo.tblCourse.Hole11, dbo.tblCourse.Hole12, dbo.tblCourse.Hole13,
dbo.tblCourse.Hole14, dbo.tblCourse.Hole15, dbo.tblCourse.Hole16,
dbo.tblCourse.Hole17, dbo.tblCourse.Hole18, dbo.tblCourse.T,
dbo.tblCourse.Rating, dbo.tblCourse.Slope, dbo.tblPlayers.Player_ID,
dbo.tblPlayers.PlayerLastName, dbo.tblPlayers.PlayerFirstName,
dbo.tblPlayers.PlayerNickName, dbo.tblScores.H4, dbo.tblScores.H5,
dbo.tblScores.H6, dbo.tblScores.H7, dbo.tblScores.H8, dbo.tblScores.H9,
dbo.tblScores.H10, dbo.tblScores.H11, dbo.tblScores.H12,
dbo.tblScores.H13, dbo.tblScores.H14, dbo.tblScores.H15,
dbo.tblScores.H16, dbo.tblScores.H17, dbo.tblScores.H18,
dbo.tblScores.B9, dbo.tblScores.T18, dbo.tblScores.P1, dbo.tblScores.F9,
dbo.tblScores.P2, dbo.tblScores.P3, dbo.tblScores.P4, dbo.tblScores.P5,
dbo.tblScores.P6,
dbo.tblScores.P7, dbo.tblScores.P8, dbo.tblScores.P9, dbo.tblScores.P10,
dbo.tblScores.P11, dbo.tblScores.P12, dbo.tblScores.P13,
dbo.tblScores.P15, dbo.tblScores.P14,
dbo.tblScores.P16, dbo.tblScores.P17, dbo.tblScores.P18,
dbo.tblScores.FW1, dbo.tblScores.FW2, dbo.tblScores.FW3,
dbo.tblScores.FW4, dbo.tblScores.FW5, dbo.tblScores.FW6,
dbo.tblScores.FW7, dbo.tblScores.FW8, dbo.tblScores.FW9,
dbo.tblScores.FW10, dbo.tblScores.FW11, dbo.tblScores.FW12,
dbo.tblScores.FW13, dbo.tblScores.FW14, dbo.tblScores.FW15,
dbo.tblScores.FW16, dbo.tblScores.FW17,
dbo.tblScores.FW18, dbo.tblScores.FWT, dbo.tblScores.TotalPutts,
dbo.tblScores.ActualDiff, dbo.tblScores.TotPars, dbo.tblScores.TotBirds,
dbo.tblScores.TotEagles, dbo.tblScores.TotBogys,
dbo.tblScores.Tot2Bogys, dbo.tblScores.AvgPutts
FROM dbo.tblScores
LEFT OUTER JOIN
dbo.tblCourse ON dbo.tblScores.Course = dbo.tblCourse.CourseID
LEFT OUTER JOIN
dbo.tblPlayers ON dbo.tblScores.Player =
dbo.tblPlayers.Player_ID
WHERE tblPlayers.Player_ID=@.PlayerID
order by date, HandiDiff;
GO
Works really well now.
Jim
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Looks like you just need date in DESCending order (the default is
ascending).
SELECT TOP 10 WITH TIES
...
ORDER BY date DESC, handidiff
Note that you may or may not want the WITH TIES option. Without it, TOP may
give non-deterministic results - if there are values where the sort columns
are equal (tied) then only some subset of the rows may be shown if the
result would otherwise give more than 10 rows.
--
David Portas
SQL Server MVP
--
> I posted another message because with your solution it gave me 10 rows by
> date which isn't exactly what I was looking for.
> I have to selection for a row of golf scores, the most current 20 rows by
> date for a particular player.
> Then I have to select the lowest 10 scores from that subset.
> Then I use those 10 to calculate the USGA Handicap Index.
> What I'm getting is the newest 10 by date which may not be the best scores|||Still have a problem with SQL. I have tried the following:
Select top 10 with ties, date, score
From tblScores
Where playerID = 3
Order by date desc, score;
The problem is that it selects the top 10 scores by date when in fact I
want the most current top 20 scores and from the most current top 20 I
want to pick the top 10 scores by lowest score.
So if I had 100 rows I would get the most current 20. From that group I
would select by score the lowest 10.
I'm not sure how TIES works but it's not doing what I wanted.
Any help would be appreciated.
Jim
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Try this:
SELECT TOP 10 WITH TIES *
FROM
(SELECT TOP 20 WITH TIES
S.[date], S.player, S.handidiff, S.tees, S.h1, S.h2, S.h3, S.course,
C.courseid, C.coursename, C.hole1, C.hole2, C.hole3, C.hole4, C.hole5,
C.hole6, C.hole7, C.hole8, C.hole9, C.hole10, C.hole11, C.hole12,
C.hole13, C.hole14, C.hole15, C.hole16, C.hole17, C.hole18, C.t,
C.rating, C.slope, P.player_id, P.playerlastname, P.playerfirstname,
P.playernickname, S.h4, S.h5, S.h6, S.h7, S.h8, S.h9, S.h10, S.h11,
S.h12, S.h13, S.h14, S.h15, S.h16, S.h17, S.h18, S.b9, S.t18,
S.p1, S.f9, S.p2, S.p3, S.p4, S.p5, S.p6, S.p7, S.p8, S.p9, S.p10,
S.p11, S.p12, S.p13, S.p15, S.p14, S.p16, S.p17, S.p18, S.fw1, S.fw2,
S.fw3, S.fw4, S.fw5, S.fw6, S.fw7, S.fw8, S.fw9, S.fw10, S.fw11,
S.fw12, S.fw13, S.fw14, S.fw15, S.fw16, S.fw17, S.fw18, S.fwt,
S.totalputts, S.actualdiff, S.totpars, S.totbirds, S.toteagles,
S.totbogys, S.tot2bogys, S.avgputts
FROM dbo.tblScores AS S
LEFT OUTER JOIN
dbo.tblCourse AS C
ON S.course = C.courseid
LEFT OUTER JOIN
dbo.tblPlayers AS P
ON S.player = P.player_id
WHERE P.player_id = @.PlayerID
ORDER BY S.[date] DESC, S.handidiff) AS T
ORDER BY handidiff
--
David Portas
SQL Server MVP
--sql
Monday, March 26, 2012
Having clause without GROUP BY clause?
What is HAVING clause equivalent in the following oracle query, without the combination of "GROUP BY" clause ?
eg :
SELECT SUM(col1) from test HAVING col2 < 5
SELECT SUM(col1) from test WHERE x=y AND HAVING col2 < 5
I want the equivalent query in MSSQLServer for the above Oracle query.
Also, does the aggregate function in Select column(here the SUM(col1)) affect in anyway the presence of HAVING clause?.
Thanks,
Gopi.those queries actually run in oracle? i rather doubt it
without a GROUP BY, the entire table is considered a single group
the individual col2 values would not necessarily all be the same, therefore the HAVING condition in the first query would not necessarily give you the results you want, assuming it even runs, which i doubt
in the second query you will surely get a syntax error even in oracle
perhaps what you want for the two queries is:
SELECT SUM(col1) from test where col2 < 5
SELECT SUM(col1) from test WHERE x=y AND col2 < 5|||Sorry for the typos. Actually the queries are as follows.
SELECT SUM(col1) from test HAVING SUM(col2) < 5
SELECT SUM(col1) from test WHERE x=y HAVING SUM(col2) < 5
Thanks,
Gopi.|||do you have sql server? if so, why don't you test those queries and see what you get
Having Clause in MDX
I have the following relationships,
DimTest > FactTestScores <- DimStudents
so if I have 5 tests, A, B, C, D, E
how do I write an MDX statement to get all students who have taken all 3 tests (not just one of the 3) A,B,C ?
pseudocode: something like this would work?
SELECT {} on 0, DimStudents.Members on 1
FROM CUBE
WHERE (A,B,C)
can I use HAVING CLAUSE anywhere to make this work?
http://www.biblogs.com/2006/01/26/the-having-clause/
thanks
Assuming that there is a "count" measure on FactTestScores like [TestCount]:
With Set [SelectedTests] as {A, B, C}
select {} on 0,
DimStudent.Student.Student.Members
Having Count(NonEmpty([SelectedTests],
{[Measures].[TestCount]})
= Count([SelectedTests] ) on 1
from CUBE
|||thank you Deepak
Please remind me one of these days how I can get you a gift to thank you for all your help.
having clause and where clause
select ...
group by col1
having col1 is not null
Does it always return the same result as
select ...
where col1 is not null
group by col1
?
The "where" one should have better performance, is it always true?Having gets evaluated after all the results have been returned and
aggregates calculated.
Where gets evaluated as the results are returned. At which point the filter
happens depends on the execution plan, but it will always be prior to
aggregation.
As a rule, only criteria on aggregate columns (sum, count, etc.) should be
in the having clause. Everything else belongs in the where.
Where SHOULD always be more efficient than having. HOWEVER, it is possible
(but highly unlikely) that the difference could cause SQL Server to use a
different execution plan that by some freak coincidence would perform better
with the having than the where. This would be the exception, and I would be
rather surprised if anyone could come up with such a case.
"nick" <nick@.discussions.microsoft.com> wrote in message
news:D3E95AF6-9550-4842-A62E-9B78A93AFC19@.microsoft.com...
> for the following SQL statement
> select ...
> group by col1
> having col1 is not null
> Does it always return the same result as
> select ...
> where col1 is not null
> group by col1
> ?
> The "where" one should have better performance, is it always true?|||They should return the same result. However, the version with the where
clause is (IMHO) better code. Where should be used when you want to compare
on the values in each row, use haveing when you want to compare on
aggregated values. So the SQL to retrive all customers with orders totaling
more than $1000 from New York would be something like:
Select ...
Where State = 'NY'
Group By CustomerID
Having Amount > 1000
Tom
"nick" <nick@.discussions.microsoft.com> wrote in message
news:D3E95AF6-9550-4842-A62E-9B78A93AFC19@.microsoft.com...
> for the following SQL statement
> select ...
> group by col1
> having col1 is not null
> Does it always return the same result as
> select ...
> where col1 is not null
> group by col1
> ?
> The "where" one should have better performance, is it always true?|||Use having ONLY if you cannot achieve the functionality through the where
clause.
In case of having the result set is already generated and the filter is
applied.
And in this particular case that you have mentioned there won't be any
difference in the result (or so I think).
having a select statement with no output
i cant modify the query but i can add to it;
what i want is to cancel the output of this query so it has no output( just like an update or insert query). a way for doing this is using 'select into' a #temp table but i cant do this becoz adding the 'into' at the end wont work after the 'from'.
i can use 'union all' to add another select statement but i cant use 'into' in the second statement becoz it has to be in the first one.
adding 'where 1=2' is not what i want becoz it still gives an empty output
any way to do this ?
thxCan you only add to the end of it? If you just add "--" to the front of it it won't execute at all, and you won't get any output.
This is certainly one of the strange requests I've seen on this forum. Why do you wan't a select statements with no output? Are you doing debugging or some sort of iterative process automation?
blindman|||thx for ur reply
i cant add to the front becoz it's a written query that i cant modify but can only add a string to the end before it is executed.
my prob is solved now after i found my source files and now i can modify the query..
thx|||I STILL have no idea...
WOAC radio
Having 2 CALCULATE statements no longer works after installing SP2!!!
I received the following email from a collegue of mine:
I think we may have found an issue with SQL SERVER 2005 SP2
1. Some of the Analysis Services Properties when you click the advanced tab are missing!
2. The MDX scrip behaviour is not the same.
In our cubes we had two CALCULATE statements - first to aggregate the data as normal, then some code to calculate MTD and YTD figures and then another CALCULATE statement. This enabled us to calculate percentages later on in the script without having to sum up all the data at leaf levels first.
With SP2, this no longer works!!! All our percentages are now being added up (like all other measures) which is clearly wrong!
I am not sure how to deal with this. Do we need to inform the clients not to upgrade to SP2 OR can Microsoft resolve this?
Any ideas?
Actually, two CALCULATE statements are the same as one CALCULATE statement w.r.t. aggregating data. The only difference could be if you have unary operators/custom rollups etc. So I suspect the use of two CALCULATE in your scenario was redundant. There is probably something else going on. If you will paste your MDX Script here, perhaps somebody will be able to figure it out.|||Thanks for the reply Mosha. I will get my collegue to post an example.|||Hello Mosha,
Attached is the MDX Script.
All it does is - FIRST calculates MTD and YTD values
Then calcualtes some percentages.
Prior to Service Pack 2, these percentage calculations displayed correct number when MTD was selected on the FLOW dimension.
Post Service Pack 2, its seems that the percentages are getting calculated first and then the MTD logic is being applied resulting in the addition of all percentages from the lowest level which is not the desired behaviour.
I have tried removing the second calculate statement and it still does not work in sp2.
thanks for your help.
/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;
/* Calculate Values for Flow Dimension */
SCOPE([Flow].[KeyFlow].&[MTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Month],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
SCOPE([Flow].[KeyFlow].&[YTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Year],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
/*Calculate again for the flow calculations to aggregate */
CALCULATE;
/*Scope Total Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[14]);
[Measures].[Dealership Measure Value]= [Measure Type].[Measure Type].[Measure].&[1] + [Measure Type].[Measure Type].[Measure].&[2] + [Measure Type].[Measure Type].[Measure].&[3];
END SCOPE;
/*Scope %Leads From Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[16]);
[Measures].[Dealership Measure Value]=
CASE [Measure Type].[Measure Type].[Measure].&[14]
WHEN 0 THEN null
WHEN null THEN null
ELSE [Measure Type].[Measure Type].[Measure].&[4]/[Measure Type].[Measure Type].[Measure].&[14]
END;
END SCOPE;
Just to add to the issue.
The percentages are not even added up. I am not sure what values it is calculating. We will raise a call with support.
Punita
|||I am having a problem with MTD() and YTD() after installing SP2. I have had to repair alot of queries since we went to SP2. I replaced the MTD and YTD functions with the PeriodsToDate() function and I was back in business. Hope that helps.Having 2 CALCULATE statements no longer works after installing SP2!!!
I received the following email from a collegue of mine:
I think we may have found an issue with SQL SERVER 2005 SP2
1. Some of the Analysis Services Properties when you click the advanced tab are missing!
2. The MDX scrip behaviour is not the same.
In our cubes we had two CALCULATE statements - first to aggregate the data as normal, then some code to calculate MTD and YTD figures and then another CALCULATE statement. This enabled us to calculate percentages later on in the script without having to sum up all the data at leaf levels first.
With SP2, this no longer works!!! All our percentages are now being added up (like all other measures) which is clearly wrong!
I am not sure how to deal with this. Do we need to inform the clients not to upgrade to SP2 OR can Microsoft resolve this?
Any ideas?
Actually, two CALCULATE statements are the same as one CALCULATE statement w.r.t. aggregating data. The only difference could be if you have unary operators/custom rollups etc. So I suspect the use of two CALCULATE in your scenario was redundant. There is probably something else going on. If you will paste your MDX Script here, perhaps somebody will be able to figure it out.|||Thanks for the reply Mosha. I will get my collegue to post an example.|||Hello Mosha,
Attached is the MDX Script.
All it does is - FIRST calculates MTD and YTD values
Then calcualtes some percentages.
Prior to Service Pack 2, these percentage calculations displayed correct number when MTD was selected on the FLOW dimension.
Post Service Pack 2, its seems that the percentages are getting calculated first and then the MTD logic is being applied resulting in the addition of all percentages from the lowest level which is not the desired behaviour.
I have tried removing the second calculate statement and it still does not work in sp2.
thanks for your help.
/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;
/* Calculate Values for Flow Dimension */
SCOPE([Flow].[KeyFlow].&[MTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Month],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
SCOPE([Flow].[KeyFlow].&[YTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Year],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
/*Calculate again for the flow calculations to aggregate */
CALCULATE;
/*Scope Total Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[14]);
[Measures].[Dealership Measure Value]= [Measure Type].[Measure Type].[Measure].&[1] + [Measure Type].[Measure Type].[Measure].&[2] + [Measure Type].[Measure Type].[Measure].&[3];
END SCOPE;
/*Scope %Leads From Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[16]);
[Measures].[Dealership Measure Value]=
CASE [Measure Type].[Measure Type].[Measure].&[14]
WHEN 0 THEN null
WHEN null THEN null
ELSE [Measure Type].[Measure Type].[Measure].&[4]/[Measure Type].[Measure Type].[Measure].&[14]
END;
END SCOPE;
Just to add to the issue.
The percentages are not even added up. I am not sure what values it is calculating. We will raise a call with support.
Punita
|||I am having a problem with MTD() and YTD() after installing SP2. I have had to repair alot of queries since we went to SP2. I replaced the MTD and YTD functions with the PeriodsToDate() function and I was back in business. Hope that helps.Having 2 CALCULATE statements no longer works after installing SP2!!!
I received the following email from a collegue of mine:
I think we may have found an issue with SQL SERVER 2005 SP2
1. Some of the Analysis Services Properties when you click the advanced tab are missing!
2. The MDX scrip behaviour is not the same.
In our cubes we had two CALCULATE statements - first to aggregate the data as normal, then some code to calculate MTD and YTD figures and then another CALCULATE statement. This enabled us to calculate percentages later on in the script without having to sum up all the data at leaf levels first.
With SP2, this no longer works!!! All our percentages are now being added up (like all other measures) which is clearly wrong!
I am not sure how to deal with this. Do we need to inform the clients not to upgrade to SP2 OR can Microsoft resolve this?
Any ideas?
Actually, two CALCULATE statements are the same as one CALCULATE statement w.r.t. aggregating data. The only difference could be if you have unary operators/custom rollups etc. So I suspect the use of two CALCULATE in your scenario was redundant. There is probably something else going on. If you will paste your MDX Script here, perhaps somebody will be able to figure it out.|||Thanks for the reply Mosha. I will get my collegue to post an example.|||Hello Mosha,
Attached is the MDX Script.
All it does is - FIRST calculates MTD and YTD values
Then calcualtes some percentages.
Prior to Service Pack 2, these percentage calculations displayed correct number when MTD was selected on the FLOW dimension.
Post Service Pack 2, its seems that the percentages are getting calculated first and then the MTD logic is being applied resulting in the addition of all percentages from the lowest level which is not the desired behaviour.
I have tried removing the second calculate statement and it still does not work in sp2.
thanks for your help.
/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;
/* Calculate Values for Flow Dimension */
SCOPE([Flow].[KeyFlow].&[MTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Month],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
SCOPE([Flow].[KeyFlow].&[YTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Year],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
/*Calculate again for the flow calculations to aggregate */
CALCULATE;
/*Scope Total Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[14]);
[Measures].[Dealership Measure Value]= [Measure Type].[Measure Type].[Measure].&[1] + [Measure Type].[Measure Type].[Measure].&[2] + [Measure Type].[Measure Type].[Measure].&[3];
END SCOPE;
/*Scope %Leads From Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[16]);
[Measures].[Dealership Measure Value]=
CASE [Measure Type].[Measure Type].[Measure].&[14]
WHEN 0 THEN null
WHEN null THEN null
ELSE [Measure Type].[Measure Type].[Measure].&[4]/[Measure Type].[Measure Type].[Measure].&[14]
END;
END SCOPE;
Just to add to the issue.
The percentages are not even added up. I am not sure what values it is calculating. We will raise a call with support.
Punita
|||I am having a problem with MTD() and YTD() after installing SP2. I have had to repair alot of queries since we went to SP2. I replaced the MTD and YTD functions with the PeriodsToDate() function and I was back in business. Hope that helps.Having 2 CALCULATE statements no longer works after installing SP2!!!
I received the following email from a collegue of mine:
I think we may have found an issue with SQL SERVER 2005 SP2
1. Some of the Analysis Services Properties when you click the advanced tab are missing!
2. The MDX scrip behaviour is not the same.
In our cubes we had two CALCULATE statements - first to aggregate the data as normal, then some code to calculate MTD and YTD figures and then another CALCULATE statement. This enabled us to calculate percentages later on in the script without having to sum up all the data at leaf levels first.
With SP2, this no longer works!!! All our percentages are now being added up (like all other measures) which is clearly wrong!
I am not sure how to deal with this. Do we need to inform the clients not to upgrade to SP2 OR can Microsoft resolve this?
Any ideas?
Actually, two CALCULATE statements are the same as one CALCULATE statement w.r.t. aggregating data. The only difference could be if you have unary operators/custom rollups etc. So I suspect the use of two CALCULATE in your scenario was redundant. There is probably something else going on. If you will paste your MDX Script here, perhaps somebody will be able to figure it out.|||Thanks for the reply Mosha. I will get my collegue to post an example.|||Hello Mosha,
Attached is the MDX Script.
All it does is - FIRST calculates MTD and YTD values
Then calcualtes some percentages.
Prior to Service Pack 2, these percentage calculations displayed correct number when MTD was selected on the FLOW dimension.
Post Service Pack 2, its seems that the percentages are getting calculated first and then the MTD logic is being applied resulting in the addition of all percentages from the lowest level which is not the desired behaviour.
I have tried removing the second calculate statement and it still does not work in sp2.
thanks for your help.
/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;
/* Calculate Values for Flow Dimension */
SCOPE([Flow].[KeyFlow].&[MTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Month],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
SCOPE([Flow].[KeyFlow].&[YTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Year],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
/*Calculate again for the flow calculations to aggregate */
CALCULATE;
/*Scope Total Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[14]);
[Measures].[Dealership Measure Value]= [Measure Type].[Measure Type].[Measure].&[1] + [Measure Type].[Measure Type].[Measure].&[2] + [Measure Type].[Measure Type].[Measure].&[3];
END SCOPE;
/*Scope %Leads From Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[16]);
[Measures].[Dealership Measure Value]=
CASE [Measure Type].[Measure Type].[Measure].&[14]
WHEN 0 THEN null
WHEN null THEN null
ELSE [Measure Type].[Measure Type].[Measure].&[4]/[Measure Type].[Measure Type].[Measure].&[14]
END;
END SCOPE;
Just to add to the issue.
The percentages are not even added up. I am not sure what values it is calculating. We will raise a call with support.
Punita
|||I am having a problem with MTD() and YTD() after installing SP2. I have had to repair alot of queries since we went to SP2. I replaced the MTD and YTD functions with the PeriodsToDate() function and I was back in business. Hope that helps.Having 2 CALCULATE statements no longer works after installing SP2!!!
I received the following email from a collegue of mine:
I think we may have found an issue with SQL SERVER 2005 SP2
1. Some of the Analysis Services Properties when you click the advanced tab are missing!
2. The MDX scrip behaviour is not the same.
In our cubes we had two CALCULATE statements - first to aggregate the data as normal, then some code to calculate MTD and YTD figures and then another CALCULATE statement. This enabled us to calculate percentages later on in the script without having to sum up all the data at leaf levels first.
With SP2, this no longer works!!! All our percentages are now being added up (like all other measures) which is clearly wrong!
I am not sure how to deal with this. Do we need to inform the clients not to upgrade to SP2 OR can Microsoft resolve this?
Any ideas?
Actually, two CALCULATE statements are the same as one CALCULATE statement w.r.t. aggregating data. The only difference could be if you have unary operators/custom rollups etc. So I suspect the use of two CALCULATE in your scenario was redundant. There is probably something else going on. If you will paste your MDX Script here, perhaps somebody will be able to figure it out.|||Thanks for the reply Mosha. I will get my collegue to post an example.|||Hello Mosha,
Attached is the MDX Script.
All it does is - FIRST calculates MTD and YTD values
Then calcualtes some percentages.
Prior to Service Pack 2, these percentage calculations displayed correct number when MTD was selected on the FLOW dimension.
Post Service Pack 2, its seems that the percentages are getting calculated first and then the MTD logic is being applied resulting in the addition of all percentages from the lowest level which is not the desired behaviour.
I have tried removing the second calculate statement and it still does not work in sp2.
thanks for your help.
/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;
/* Calculate Values for Flow Dimension */
SCOPE([Flow].[KeyFlow].&[MTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Month],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
SCOPE([Flow].[KeyFlow].&[YTD]);
THIS = (Sum(PeriodsToDate([Period].[Calendar].[Year],[Period].[Calendar].CurrentMember),([Measures].CurrentMember, [Flow].[KeyFlow].&[P])));
END SCOPE;
/*Calculate again for the flow calculations to aggregate */
CALCULATE;
/*Scope Total Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[14]);
[Measures].[Dealership Measure Value]= [Measure Type].[Measure Type].[Measure].&[1] + [Measure Type].[Measure Type].[Measure].&[2] + [Measure Type].[Measure Type].[Measure].&[3];
END SCOPE;
/*Scope %Leads From Traffic */
SCOPE([Measure Type].[Measure Type].[Measure].&[16]);
[Measures].[Dealership Measure Value]=
CASE [Measure Type].[Measure Type].[Measure].&[14]
WHEN 0 THEN null
WHEN null THEN null
ELSE [Measure Type].[Measure Type].[Measure].&[4]/[Measure Type].[Measure Type].[Measure].&[14]
END;
END SCOPE;
Just to add to the issue.
The percentages are not even added up. I am not sure what values it is calculating. We will raise a call with support.
Punita
|||I am having a problem with MTD() and YTD() after installing SP2. I have had to repair alot of queries since we went to SP2. I replaced the MTD and YTD functions with the PeriodsToDate() function and I was back in business. Hope that helps.sqlMonday, March 19, 2012
Has anyone ever seen this fatal error?
on one of our clusters:
Server: Msg 7105, Level 22, State 6, Line 8
Page (1:16750), slot 4 for text, ntext, or image node does
not exist.
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
We are running SQL Server 2000 with SP3.
DBCC CHECKDB showed a problem with an index which we fixed
but the error still shows when we run the SP. DBCC
CHECKDB now shows no problems.
Is there any other way to track down this problem and/or
repair it?To resolve this problem, obtain the lates service pack for
Microsoft SQL Server 2000.
To work around the problem, either:
- Insert a dummy row in the table to import into so that
the table is not empty, and then delete the dummy row
after you import the data.
-or-
- Do not use the TABLOCK hint.
This posting is provided "AS IS" with no warranties, and
confers no rights.
http://www.microsoft.com/info/cpyright.htm
>--Original Message--
>We are getting the following error after execcuting an SP
>on one of our clusters:
>Server: Msg 7105, Level 22, State 6, Line 8
>Page (1:16750), slot 4 for text, ntext, or image node
does
>not exist.
>ODBC: Msg 0, Level 16, State 1
>Communication link failure
>Connection Broken
>We are running SQL Server 2000 with SP3.
>DBCC CHECKDB showed a problem with an index which we
fixed
>but the error still shows when we run the SP. DBCC
>CHECKDB now shows no problems.
>Is there any other way to track down this problem and/or
>repair it?
>
>.
>
Harish Mohanbabu
How to create jobs in MS SQL Server 2000 for the following purposes -
1. For re-organise/re-index to 10% per page &
2. For checking DB integrity.
Can someone let me know please.
TIA,
Harish
*********************************
Long way to go before I sleep ..
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Hello Harish,
If you want the quick and dirty way use the maintenance wizard for this. If
you want scripts for this I can email some that I use.
Let me know if need to know how to run the maintenance wizard. Or just look
it up in the books online for SQL server, this is an excellent resource with
walk throughs and examples.
John...
"Harish Mohanbabu" <Harish@.nospam.com> wrote in message
news:eZ6VCrU$DHA.1732@.TK2MSFTNGP12.phx.gbl...
> Hi,
> How to create jobs in MS SQL Server 2000 for the following purposes -
> 1. For re-organise/re-index to 10% per page &
> 2. For checking DB integrity.
> Can someone let me know please.
> TIA,
> Harish
>
> *********************************
> Long way to go before I sleep ..
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
Harish Mohanbabu
How to create jobs in MS SQL Server 2000 for the following purposes -
1. For re-organise/re-index to 10% per page &
2. For checking DB integrity.
Can someone let me know please.
TIA,
Harish
*********************************
Long way to go before I sleep ..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Go to Enterprise Manager/management/database mainenance
plans. You can right click and select "new maintenance
plan", you just select the databases you want to setup and
it will walk you through the rest. You can also setup
full/tran log backups. You will then see the additions of
new jobs.
Hope that helps
thanks
Susan
>--Original Message--
>Hi,
>How to create jobs in MS SQL Server 2000 for the
following purposes -
>1. For re-organise/re-index to 10% per page &
>2. For checking DB integrity.
>Can someone let me know please.
>TIA,
>Harish
>
>*********************************
>Long way to go before I sleep ..
>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.
>|||Hello Harish,
If you want the quick and dirty way use the maintenance wizard for this. If
you want scripts for this I can email some that I use.
Let me know if need to know how to run the maintenance wizard. Or just look
it up in the books online for SQL server, this is an excellent resource with
walk throughs and examples.
John...
"Harish Mohanbabu" <Harish@.nospam.com> wrote in message
news:eZ6VCrU$DHA.1732@.TK2MSFTNGP12.phx.gbl...
> Hi,
> How to create jobs in MS SQL Server 2000 for the following purposes -
> 1. For re-organise/re-index to 10% per page &
> 2. For checking DB integrity.
> Can someone let me know please.
> TIA,
> Harish
>
> *********************************
> Long way to go before I sleep ..
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Friday, March 9, 2012
Hardware general question about sql
Nowadays, we have got an Active-Active cluster for to attend our business as
usual. Each node own the following main features:
-8 processors xeon 700 Mhz
-8 Gb RAM
-RAID 5 (up to 400 gb ) 12 disks approx.
-OS 32 bit (Advanced Server)
-Sql2000k with sp3
-Quorum disk have 36,6 GB
-Our growing per w
-Databases are forty.
The above configuration was bough five years ago, so that, which could be a
good migration of this hardware?
We are thinking over to buy Itanium but we don't know if TCO is good with
such growing of data.
Maybe a good solution will be buy 64-bit hardware and by the moment to
install our sql2000k and within six months or so (when SP1 for sql server
2005 is released) move the data to that version.
Any input will be greatly.
Regards,Enric wrote:
> Dear folks,
> Nowadays, we have got an Active-Active cluster for to attend our
> business as usual. Each node own the following main features:
> -8 processors xeon 700 Mhz
> -8 Gb RAM
> -RAID 5 (up to 400 gb ) 12 disks approx.
> -OS 32 bit (Advanced Server)
> -Sql2000k with sp3
> -Quorum disk have 36,6 GB
> -Our growing per w
> -Databases are forty.
> The above configuration was bough five years ago, so that, which
> could be a good migration of this hardware?
> We are thinking over to buy Itanium but we don't know if TCO is good
> with such growing of data.
> Maybe a good solution will be buy 64-bit hardware and by the moment to
> install our sql2000k and within six months or so (when SP1 for sql
> server 2005 is released) move the data to that version.
> Any input will be greatly.
> Regards,
What hardware issues, if any, are you currently having? Assuming your
queries are performance tuned (which should always be the first order of
business when it comes to performance), you need to determine where the
hardware is failing you. Are you CPU bound? Disk bound? Memory bound?
50GB of growth per w
w
you much time.
You have a powerful, but older server. You could probably get better
performance out of a modern 4-way Xeon server. Since SQL 2005 will run
on 64-bit AMD and x86 boxes, I might consider waiting for that version
and skip Itanium.
If you determine that you are disk bound, you may want to consider using
a SAN or a different RAID implementation. It sounds like you have RAID 5
for everything (data, logs, temdb). You will normally get much better
performance using a RAID 1+0 array for data, and RAID 1+0 or RAID 1
arrays for log files and tempdb. Unless activity is low during log
backups and full backups, you may want to consider backing up to an
array that's different than the data array.
David Gugick
Quest Software
www.imceda.com
www.quest.com|||If you're not experiencing any problems with your current set-up, and the SW
side is fully optimized, then IMHO you don't really have to change anything.
ML
Hardest Query of My Life.. :) (Help Please!)
pmt_id (pk)
pmt_link_id (fk to an "account")
pmt_code
pmt_recovery (1 or 0)
The Account table has:
lcl_id (pk)
pmt_link_id (used as fk to payment)
I need to write a query that will tell me a list of Accounts that have a
recovery='1' (for a distinct pmt_code) that does NOT have a payment (where
recovery='0') for that account also...is that even possible?
Message posted via http://www.webservertalk.comTry this:
SELECT lcl_id
FROM Account AS A
JOIN Payment AS P
ON A.pmt_link_id = P.pmt_link_id
GROUP BY lcl_id
HAVING MIN(pmt_recovery)=1
If that's not it, please follow the advice in this article on how best
to post your problem here:
http://www.aspfaq.com/etiquette.asp?id=5006
David Portas
SQL Server MVP
--|||Try this
select a.lcl_id,a.pmt_link_id from Account as a
inner join payment as b on a.lcl_id=b.pmt_link_id and b.pmt_recovery=1
left join (select distinct pmt_link_id from payment where recovery=0) as c
on a.lcl_id=c.pmt_link_id
where c.pmt_link_id is NULL
Babu M K
Comat Technologies Pvt. Ltd
"Jon Jensen via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:08764836d2f54d06945788f5edb81020@.SQ
webservertalk.com...
> I have a payment table that has the following (important) fields:
> pmt_id (pk)
> pmt_link_id (fk to an "account")
> pmt_code
> pmt_recovery (1 or 0)
> The Account table has:
> lcl_id (pk)
> pmt_link_id (used as fk to payment)
> I need to write a query that will tell me a list of Accounts that have a
> recovery='1' (for a distinct pmt_code) that does NOT have a payment (where
> recovery='0') for that account also...is that even possible?
> --
> Message posted via http://www.webservertalk.com|||Minor change in the query
select a.lcl_id,a.pmt_link_id from Account as a
inner join payment as b on a.pmt_link_id=b.pmt_link_id and b.pmt_recovery=1
left join (select distinct pmt_link_id from payment where recovery=0) as c
on a.pmt_link_id=c.pmt_link_id
where c.pmt_link_id is NULL
Babu
Comat Technologies Pvt. Ltd
"Jon Jensen via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:08764836d2f54d06945788f5edb81020@.SQ
webservertalk.com...
> I have a payment table that has the following (important) fields:
> pmt_id (pk)
> pmt_link_id (fk to an "account")
> pmt_code
> pmt_recovery (1 or 0)
> The Account table has:
> lcl_id (pk)
> pmt_link_id (used as fk to payment)
> I need to write a query that will tell me a list of Accounts that have a
> recovery='1' (for a distinct pmt_code) that does NOT have a payment (where
> recovery='0') for that account also...is that even possible?
> --
> Message posted via http://www.webservertalk.com|||"Jon Jensen via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:08764836d2f54d06945788f5edb81020@.SQ
webservertalk.com...
>I have a payment table that has the following (important) fields:
> pmt_id (pk)
> pmt_link_id (fk to an "account")
> pmt_code
> pmt_recovery (1 or 0)
> The Account table has:
> lcl_id (pk)
> pmt_link_id (used as fk to payment)
> I need to write a query that will tell me a list of Accounts that have a
> recovery='1' (for a distinct pmt_code) that does NOT have a payment (where
> recovery='0') for that account also...is that even possible?
> --
> Message posted via http://www.webservertalk.com
If that's the "hardest query of your life", then
you've had a relatively easy life of writing
queries thus far <grin>.
Hardcode subtotal
Hello,
Can I hardcode matrix subtotal?
For instance, I want to hardcode "100%" in the following Sales report:
2007 Year
Quantity
Phones 21%
Notebooks 30%
Total 100%
Please don't ask me why I need to do that, it's a complex MDX query and the report is much more complex than I depicted.
I just need to statically write 100% in subtotal.
Write the following expression
Code Snippet
=100 & "%" in the text box where u want to display 100%.Best Regards,
Rajiv
|||
RajivDotNet wrote:
Write the following expression
Code Snippet
=100 & "%" in the text box where u want to display 100%.Best Regards,
Rajiv
I would just like to mention the InScope function. If you have a calculation in that column to determine the percentage, you can just add an IIf and InScope function to the expression to determine whether you are within the bounds of your row group, if you are within bounds then do your normal percentage calculation, if you are out of bounds then just return "100" (and use the code p0 in the Format property so that things are formatted correctly when exported to Excel).
|||Dear Rajiv and Sluggy,
Thank you very much for your quick response.
Your approach worked!
Monday, February 27, 2012
Handling variables
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Public GetFilePath As String = ""
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
GetFilePath = "C:\Rapagator\Downloaded" + Row.FileName
End Sub
Public Overrides Sub PostExecute()
Variables.FilePath = GetFilePath
MyBase.PostExecute()
End Sub
End Class
How do you know the variable value is only the filename part you state? You cannot debug inside the Script Component, so perhaps add a MessageBox or log an event to write out the values you have just to be sure. Perhaps set a breakpoint as well and add the variable to the watch window. You do know that the Variables window only shows design-time values during runtime, even when completed or stopped on a breakpoint. Use the watch window to get real values. This does seem rather strange, are you only expecting one row to flow through this component; otherwise you will only store the last row's value in the variable. Is that what you want?
Does the filename start with a "\" ? If not the path looks invalid - C:\Rapagator\DownloadedMYFILE. Top tip, use System.IO.Path.Combine(x, y) as that will sort out path qualifiers for you.
Handling SQLServerCE DataBase By windows application ?
Hi
i have the following problem :
i attempted to connect with a SQLServerCE DataBase
to Insert and update its rows, but i noticed that i want the reference :
System.Data.SqlServerCe
i went to (Add references) but i didn't find it ..
what should i do to break this problem ?
please help me !
Hi Imad
I have moved your treat to the Devices team who should be able to help you
mairead
PM, TS Data
|||Hello and sorry for the delayed reply.
Just a question first - are you attemping to open a SqlServerCe database on your desktop PC or on a mobile device (like a Pocket PC / Smartphone)? This is important because we want to add the correct DLL to your project.
If you're opening the database on the desktop, then we can find the System.Data.SqlServerCe.DLL in the directory where DEVENV.EXE is. That would be something like C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
If you're opening the database on a device, then we can find the System.Data.SqlServerCe.DLL in the Mobile SDK folder. That would be something like C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0
If either of the DLLs are missing then it means your SQLServerCe SDK is not installed on your machine. The easiest way to fix this is to REPAIR the visual studio installation. This will re-install the SDK and ensure the DLLs are present on the machine.
Please let me know how it works out,
Kind regards,
Carlton Lane
Microsoft Visual Basic Team
|||I am trying to use desktop application to open a Sqlserverce database that located on the PDA. but it throw this exception:
Unable to load DLL 'sqlceme30.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I checked and see System.Data.SqlServerCe.DLL exists under:
D:\Program Files\Microsoft Visual Studio 8\Common7\IDE
D:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0
Actually it throw that exception no matter what database I am trying to open. here is my code:
connStr = "Data Source =""Mobile Device\Program Files\Barcode_PDA\pda.sdf"";"
conn1 = New SqlServerCe.SqlCeConnection(connStr) < this generates the error
Thanks for your help!
|||Hi Alex,
I'm sorry but the scenairo of opening a database on a device remotely from a desktop PC isnt supported by the SQLCE engine. Eventually, you'll get an error about the connection string being invalid. This is because the engine is targeting local data scenarios - that is where the Application and Database reside on the same machine, in the same process. This scenario starts to touch on client / server scenarios which currently arent supported.
Your current error about the missing dlls is telling us that the application is starting but cant find the engine. These dlls are found next to the System.Data.SqlServerCe.dll file. The ones in the Common7\IDE are for your PC. THe ones in SmartDevices\SDK are for the device. For a PC application, copy the ones from Common7\IDE into the executing directory of your application. But again, after you get pass this error, you will eventually get an error about the connection string being invalid because this scenario isnt supported.
HTH and good luck,
Carlton
|||hi everybody
first thank you for helping me ..
but i want to tell you that i have solved my problem easily by installing sql server everywhere edition CTP
to install sql serverce tools and then all dll's have been loaded correctly ..