Showing posts with label somebody. Show all posts
Showing posts with label somebody. Show all posts

Friday, March 30, 2012

Hide matrix rows?

Hi,

can somebody help me figuring out if the following is possible?
I have a matrix creating weeks out on "x-axis" and projects at "y-axis". For each project have i specified three rows, sum(Fields!hours.Value), sum(Fields!used.Value) and a total saying (sum)Fields!used.Value - sum(Fields!hours.Value).

12 13 14 15 16
A 3 4 5 3 4
2 4 3 4 1
-1 0 -2 1 -3

B ... and so forth...

What i would like is to have only the total row displayed initially, and the through drill-down on clicking A being able to se the two columns used to calculate the total.

I can't seem to figure it out.

Hope somebody out there has an idea for this - or can say that it cant be done for sure.. :-)

Best RegardsYou need to set the inner group (in the group properties) to be initially hidden and toggle the group visibility on the textbox. Make sure you have subtotals turned on (click on the outer group and select 'display subtotals').|||Thanks for the answer, but I can't seem to get this right.

I think maybe the problem is that i don't have anything to group for. Theres nothing that i can group so that the three rows becomes one. They are all just different sums of the one row in the dataset.

Am i getting it wrong? If i select one of the three fields i cant seem to select the "toggle visibility".

Can you follow me?|||

You always have a group in the matrix. If you aren't using any grouping, then you probably should be using a table dataregion. Can you bring up the matrix properties? Also, you could give more of an idea what you are trying to do.

|||

Hi Brian,

I have a similar problem and I wandered if you answer is what I might possibly need, but I haven't been able to implement it.

This is the part of my report. I have first group row being same company branch, second group row are clients and the third one is destinations where those clients were travelling. The measurement is the amount they spent on those destinations. This is the expanded version which look as it should. But look below for not expanded version and that is the one I have problem with.

Leisure

2005

2006

2007

Al

X company

AU

751458.06

298819.34

NZ

302619.79

121497.81

0

US/CA

270860.44

218673.12

SPAC

172093.03

96573.88

ASIA

164682.67

81023.22

UK/EUR

932738.37

481519.72

OTH

54430.17

62402.62

Total

2648882.53

1360509.71

0

Living Options Charitable Trust

AU

Total

Total

2657071.43

1360509.71

0

What I would like to see in not expanded version is just totals for the group rows. But what I am getting is suppressed description of the group rows but expended amounts as in the previous version. There is a little + next to Al in my version to show it is not expended version but for some reson it didn't come in here.

Leisure

2005

2006

2007

Al

751458.06

298819.34

302619.79

121497.81

0

270860.44

218673.12

172093.03

96573.88

164682.67

81023.22

932738.37

481519.72

54430.17

62402.62

Total

2648882.53

1360509.71

0

Total

Total

2657071.43

1360509.71

0

Interesting enough is that when exported into excel it works as it should be but in to Reporting Services as well.

Thanks a lot

Cheers

Marina

|||

I think I found out what my problem is. I was setting up the visability on the field instead of on the group.

Thanks

Marina

|||

Hi!!, what happend with you repor, t could you find an answer? I have the same question.

sql

Hide matrix rows?

Hi,

can somebody help me figuring out if the following is possible?
I have a matrix creating weeks out on "x-axis" and projects at "y-axis". For each project have i specified three rows, sum(Fields!hours.Value), sum(Fields!used.Value) and a total saying (sum)Fields!used.Value - sum(Fields!hours.Value).

12 13 14 15 16
A 3 4 5 3 4
2 4 3 4 1
-1 0 -2 1 -3

B ... and so forth...

What i would like is to have only the total row displayed initially, and the through drill-down on clicking A being able to se the two columns used to calculate the total.

I can't seem to figure it out.

Hope somebody out there has an idea for this - or can say that it cant be done for sure.. :-)

Best RegardsYou need to set the inner group (in the group properties) to be initially hidden and toggle the group visibility on the textbox. Make sure you have subtotals turned on (click on the outer group and select 'display subtotals').|||Thanks for the answer, but I can't seem to get this right.

I think maybe the problem is that i don't have anything to group for. Theres nothing that i can group so that the three rows becomes one. They are all just different sums of the one row in the dataset.

Am i getting it wrong? If i select one of the three fields i cant seem to select the "toggle visibility".

Can you follow me?|||

You always have a group in the matrix. If you aren't using any grouping, then you probably should be using a table dataregion. Can you bring up the matrix properties? Also, you could give more of an idea what you are trying to do.

|||

Hi Brian,

I have a similar problem and I wandered if you answer is what I might possibly need, but I haven't been able to implement it.

This is the part of my report. I have first group row being same company branch, second group row are clients and the third one is destinations where those clients were travelling. The measurement is the amount they spent on those destinations. This is the expanded version which look as it should. But look below for not expanded version and that is the one I have problem with.

Leisure 2005 2006 2007 Al X company AU 751458.06 298819.34 NZ 302619.79 121497.81 0 US/CA 270860.44 218673.12 SPAC 172093.03 96573.88 ASIA 164682.67 81023.22 UK/EUR 932738.37 481519.72 OTH 54430.17 62402.62 Total 2648882.53 1360509.71 0 Living Options Charitable Trust AU Total Total 2657071.43 1360509.71 0

What I would like to see in not expanded version is just totals for the group rows. But what I am getting is suppressed description of the group rows but expended amounts as in the previous version. There is a little + next to Al in my version to show it is not expended version but for some reson it didn't come in here.

Leisure 2005 2006 2007 Al 751458.06 298819.34 302619.79 121497.81 0 270860.44 218673.12 172093.03 96573.88 164682.67 81023.22 932738.37 481519.72 54430.17 62402.62 Total 2648882.53 1360509.71 0 Total Total 2657071.43 1360509.71 0

Interesting enough is that when exported into excel it works as it should be but in to Reporting Services as well.

Thanks a lot

Cheers

Marina

|||

I think I found out what my problem is. I was setting up the visability on the field instead of on the group.

Thanks

Marina

|||

Hi!!, what happend with you repor, t could you find an answer? I have the same question.

Hide matrix rows?

Hi,

can somebody help me figuring out if the following is possible?
I have a matrix creating weeks out on "x-axis" and projects at "y-axis". For each project have i specified three rows, sum(Fields!hours.Value), sum(Fields!used.Value) and a total saying (sum)Fields!used.Value - sum(Fields!hours.Value).

12 13 14 15 16
A 3 4 5 3 4
2 4 3 4 1
-1 0 -2 1 -3

B ... and so forth...

What i would like is to have only the total row displayed initially, and the through drill-down on clicking A being able to se the two columns used to calculate the total.

I can't seem to figure it out.

Hope somebody out there has an idea for this - or can say that it cant be done for sure.. :-)

Best RegardsYou need to set the inner group (in the group properties) to be initially hidden and toggle the group visibility on the textbox. Make sure you have subtotals turned on (click on the outer group and select 'display subtotals').|||Thanks for the answer, but I can't seem to get this right.

I think maybe the problem is that i don't have anything to group for. Theres nothing that i can group so that the three rows becomes one. They are all just different sums of the one row in the dataset.

Am i getting it wrong? If i select one of the three fields i cant seem to select the "toggle visibility".

Can you follow me?|||

You always have a group in the matrix. If you aren't using any grouping, then you probably should be using a table dataregion. Can you bring up the matrix properties? Also, you could give more of an idea what you are trying to do.

|||

Hi Brian,

I have a similar problem and I wandered if you answer is what I might possibly need, but I haven't been able to implement it.

This is the part of my report. I have first group row being same company branch, second group row are clients and the third one is destinations where those clients were travelling. The measurement is the amount they spent on those destinations. This is the expanded version which look as it should. But look below for not expanded version and that is the one I have problem with.

Leisure 2005 2006 2007 Al X company AU 751458.06 298819.34 NZ 302619.79 121497.81 0 US/CA 270860.44 218673.12 SPAC 172093.03 96573.88 ASIA 164682.67 81023.22 UK/EUR 932738.37 481519.72 OTH 54430.17 62402.62 Total 2648882.53 1360509.71 0 Living Options Charitable Trust AU Total Total 2657071.43 1360509.71 0

What I would like to see in not expanded version is just totals for the group rows. But what I am getting is suppressed description of the group rows but expended amounts as in the previous version. There is a little + next to Al in my version to show it is not expended version but for some reson it didn't come in here.

Leisure 2005 2006 2007 Al 751458.06 298819.34 302619.79 121497.81 0 270860.44 218673.12 172093.03 96573.88 164682.67 81023.22 932738.37 481519.72 54430.17 62402.62 Total 2648882.53 1360509.71 0 Total Total 2657071.43 1360509.71 0

Interesting enough is that when exported into excel it works as it should be but in to Reporting Services as well.

Thanks a lot

Cheers

Marina

|||

I think I found out what my problem is. I was setting up the visability on the field instead of on the group.

Thanks

Marina

|||

Hi!!, what happend with you repor, t could you find an answer? I have the same question.

Monday, March 19, 2012

Hi

Hi,

Somebody can speak (tips) about exam 70-431?

Tips?

Amount Questions?

Time ?

....

If you're looking for brain dumps this is not the site to get those answers. The 70-431 exam is a 200-level "how-to" exam on all the nuts and bolts of SQL Server 2005. There are free eLearning classes available on the Microsoft web site which will help you with the content information for the test, as well as a number of excellent books hitting the market about now.

I believe you'll get about 40 questions on the test, though it may be higher than that, and you'll get about 2 1/2 hours to answer them.

Go to www.microsoft.com/sql and click on Learning and you'll find out all you need to know to prepare for the test.

Good luck.

|||

What is the passing mark/percentage for MCTS?

|||

Hi Gunny,

is 700 scored.

|||
E X A M S P E C S
Exam Number: 70-431
Active / Retired: Active
Prerequisites:
Exam Format: Multiple-Choice; Multiple Answer
Num Questions: 55
Time Limit: 90
Cost (USD) $: $125
Passing Score: 700

taken from cramsession's site: http://www.cramsession.com/certifications/exams/sql-server-2005.asp?exam_id=770

also use this code for 20% of the exam price

Call now to schedule your Microsoft exam call 1-800-247-8731 and use code MSUU5C7E0100 for your 20% discount.

|||

Many thanks WPH and rkohler.

That's 700 out of how many? What is the max possible score?

|||1000 max scored.|||

Thanks WPH.

|||

any one can respon

i have two server one is dpmain controller and second is exchange 2003 server i need to setup sql 2005

which one i choice ?

|||

a.m.m.e.

Your question really belongs in a separate/new thread. This thread is about MCTS.

But to answer your question, I would advise against putting it on the domain controller. The domain controller contains the Active Directory and security is extremely important. Adding any other role such as SQL Server would complicate security configuration for it.

Actually, if possible, I would set up a new dedicated SQL Server - not add it to the Exchange Server 2003. Mixing multiple roles on one server always complicates security. But if you cannot set up a new dedicated server I would add it to the Exchange Server 2003.

Other more experienced people may have different ideas.

|||

Hello everyone,

I would like to let you all know and be aware of the fact that microsoft has changed its exam pattern for

070-431 be very carefull as microsoft has changed the exam pattern and due to which i failed the exam today.

Its now based on simulations questions which comes after the multiple choice questions i got 15 simulations

separately apart from 35 multi choice questions along with exibits. I wasnt aware of this fact and it wasnt

mentioned ánywhere about simulations questions I think no one knows about it I am the first to face this type of

exam.. The exams comes up with 2 sections the first sections was questions that was 35 in 1hr and the next

was simulations that was 15 2hr 15mins so in total it was 195min exam and I got all correct in first section

and the second section was gred out 60% I got 560 out of 700 may not be difficult but very new.

If in case you have come across with any good site with simulations of this exam please forward me to

a_afroze@.yahoo.com

All the best to all of you

Abdul Afroze

|||

Hello everyone,

I would like to let you all know and be aware of the fact that microsoft has changed its exam pattern for

070-431 be very carefull as microsoft has changed the exam pattern and due to which i failed the exam today.

Its now based on simulations questions which comes after the multiple choice questions i got 15 simulations

separately apart from 35 multi choice questions along with exibits. I wasnt aware of this fact and it wasnt

mentioned ánywhere about simulations questions I think no one knows about it I am the first to face this type of

exam.. The exams comes up with 2 sections the first sections was questions that was 35 in 1hr and the next

was simulations that was 15 2hr 15mins so in total it was 195min exam and I got all correct in first section

and the second section was gred out 60% I got 560 out of 700 may not be difficult but very new.

If in case you have come across with any good site with simulations of this exam please forward me to

a_afroze@.yahoo.com

All the best to all of you

Abdul Afroze

|||

Thanks for the information. I'm going to be taking the test soon and was afraid they would do something like this. They did this to me on the 70-228... completely changed the content and format from what my rather expensive test prep materials were based on.

Could you give us a clue as to what the simulations focused on? (ie. TSQL, SSMS, etc.) I can do just about everything you need to do in SSMS and other GUI tools, but I don't have all the full syntaxes for the TSQL methods memorized (ie. create HTTP endpoint for SOAP vs. TCP endpoint for mirroring).

|||

Well, this really isn't a database documentation request, and using a questions-only site really isn't the best way to go. There are reputable firms, such as Transcender, that will help you with testing and so on. The point is that you should try and learn the trade, rather than just memorizing questions. I've posted an article that deals with certifications:

http://www.informit.com/guides/content.asp?g=sqlserver&seqNum=131

And another here dealing with being a DBA. I think you may find those more useful than looking up test questions on a site.

http://www.informit.com/guides/content.asp?g=sqlserver&seqNum=247

These are just my thoughts - I do wish you luck in your studies!

|||

Many thanks, Abdul, for that "heads up".

If you or anyone else here come to know of any test exams based on this new pattern I am sure we all would be eager to know about them as soon as possible.

Regards

Wednesday, March 7, 2012

Help: Why IN-Operator with Select-Statement it doesnt work? But with given Values it works

Hello to all,

i have a problem with IN-Operator. I cann't resolve it. I hope that somebody can help me.

I have a IN_Operator sql query like this, this sql query can work. it means that i can get a result 3418:

declare @.IDMint;

declare @.IDO varchar(8000);

set @.IDM= 3418;

set @.IDO='3430'

select*

from wtcomValidRelationshipsas A

where(A.IDMember= @.IDM)and( @.IDOin(3428, 3430, 3436, 3452, 3460, 3472, 3437, 3422, 3468, 3470, 3451, 3623, 3475, 3595, 3709, 3723, 3594, 3864, 3453, 4080))

but these numbers(3428, 3430, 3436, 3452, 3460, 3472, 3437, 3422, 3468, 3470, 3451, 3623, 3475, 3595, 3709, 3723, 3594, 3864, 3453, 4080)come from a select-statement. so if i use select-statement in this query, i get nothing back. this query like this one:

select*

from wtcomValidRelationshipsas A

where(A.IDMember= @.IDM)and( @.IDOin(select B.RelationshipIDsfrom wtcomValidRelationshipsas Bwhere B.IDMember= @.IDM))

I have checked that man can use IN-Operator with select-statement. I don't know why it doesn't work with me. Could somebody help me? Thanks

I use MS SQL 2005 Server Management Stadio Express

Thanks a million and Best regards

Sha

What is the datatype of the column B.RelationshipIDs in the view?

|||

Please try:

First, removewhere B.IDMember= @.IDM from yuor statement, see you get some records or not. if you get, it means your B.IDMember= @.IDM criteria return no records.

If this no working, try

where(A.IDMember= @.IDM)andEXISTS(SELECT B.RelationshipIDsfrom wtcomValidRelationshipsas Bwhere B.IDMember= @.IDM ANDRelationshipIDs= @.IDO).

Sometimes, IN or NOT IN doesn't work but EXISTS does.

Monday, February 27, 2012

Help: Shortest Path in sql

Hello to all,

help, help,...

i have with this problem since 3 weeks, until now i cann't resolve this problem. Maybe can somebody help me. I am hopeless.Crying

i have a data table ValidRelationship, i will check if there is a relationship between two members by this table.

datas in the table ValidRelationship:

IDMember IDOtherMember IDType

3700

372610000372637001000037423672100003672374210000342235481000035483422100003548371710000371735481000036753695100003695367510000

I will give two member and check their Relationship with a sql query. but it can be that this two member have no relationship. So i define here that man should search processor <= 6 . To better describe i use a example: max. Result of this query is: 1-2-3-4-5-6. If this is a relationship between 1-7 is 1-2-3-4-5-6-7, but i will give a answer that this is no relationship between 1-7. because processor > 6.

But my problem is: this query executing is too slow. if i habe two member no relationship, the time of this complete sql query to execute is more than 1 minutes. Is my algorithm wrong, or where is the problem, why this executing is so slow? How can i quickly get the relationships between two member, if my algorithms is not right? The following Query is only to processor = 3, but it works too slowly, so i don't write remaining processors.

declare @.IDMint;

declare @.IDOint;

set @.IDM= 3418;

set @.IDO= 4270

selecttop 1 IDMember

from v_ValidRelationships

where IDMember= @.IDM

and @.IDOin(select a.IDOtherMemberfrom v_ValidRelationshipsas awhere a.IDMember= @.IDM)

selecttop 1 a.IDMember, b.IDMember

from v_ValidRelationshipsas a, v_ValidRelationshipsas b

where a.IDMember= @.IDM

and b.IDMemberin(select c.IDOtherMemberfrom v_ValidRelationshipsas cwhere c.IDMember= @.IDM)

and @.IDOin(select d.IDOtherMemberfrom v_ValidRelationshipsas dwhere d.IDMember= b.IDMember)

selecttop 1 a.IDMember, b.IDMember, e.IDMember

from v_ValidRelationshipsas a, v_ValidRelationshipsas b, v_ValidRelationshipsas e

where a.IDMember= @.IDM

and b.IDMemberin(select c.IDOtherMemberfrom v_ValidRelationshipsas cwhere c.IDMember= @.IDM)

and e.IDMemberin(select f.IDOtherMemberfrom v_ValidRelationshipsas fwhere f.IDMember= b.IDMember)

and @.IDOin(select d.IDOtherMemberfrom v_ValidRelationships as d where d.IDMembe = e.IDMember)

If someone has a idea, please help me. Thank a million

Best Regards

Shasha

The reason it starts gumming up is because you are potentially creating millions of records for this process - in step one, you are only scanning the records in the table, but then you're exponentially scanning the table - like this example with just 10 rows:

1) Look for relationship in 10 rows

2) Look for relationship in 10 x 10 rows (100)

3) Look for relationship in 10 x 10 x 10 rows (1000)

4) Look for relationship in 10 x 10 x 10 x 10 rows (10,000)

5) 100,000

6) 1,000,000

You would have to totally revisit the structure to avoid this.

|||

Hello Sohnee,

I'm sorry that i can not good understand what you mean. Could you please explain more some details? Thank you very much.

Regards

Shasha

|||

Sorry, I don't have time to write the exact query, but perhaps someone else here wants to take a shot.

Assuming the that IDMember is "parent", and IDOtherMember is "child". Build a recursive CTE, that returns all the children of the parent up to x levels deep (columns parent,child,path_from_parent_to_child,depth).

Then using the CTE, filter only the rows where parent is equal to an input parameter, child is equal to an input parameter, and depth is equal to or less than an input parameter.

|||

@.MaxDepth determines the "number of processors". If you want to search up to 7 deep, set @.MaxDepth to 7. The results are not exactly the same, but similiar enough. The Path column will include a comma delimited list of ID's it went through to reach the other member.

DECLARE @.MaxDepthint

DECLARE @.IDMemberint

DECLARE @.IDOtherMemberint

SET @.MaxDepth=10

SET @.IDMember=3700

SET @.IDOtherMember=3726

WITH DirectReports(IDMember, IDOtherMember,Path, Depth)

AS

(

-- Anchor member definition

SELECT IDMember, IDOtherMember,','+CAST(IDMemberasvarchar(MAX))+','+CAST(IDOtherMemberASvarchar(MAX))+','ASPath, 1AS Depth

FROM ValidRelationship

WHERE IDMember=@.IDMember

UNIONALL

-- Recursive member definition

SELECT t2.IDMember, t1.IDOtherMember, t2.Path+CAST(t1.IDOtherMemberASvarchar(MAX))+','ASPath, Depth+ 1

FROM ValidRelationship t1

INNERJOIN DirectReportsAS t2ON t2.IDOtherMember= t1.IDMember

WHERECHARINDEX(','+CAST(t1.IDOtherMemberASVARCHAR(MAX))+',',t2.Path,0)=0

AND t2.Depth<@.MaxDepth

)

-- Statement that executes the CTE

SELECTTOP 1 IDMember,IDOtherMember,SUBSTRING(Path,2,LEN(path)-2),Depth

FROM DirectReports

WHERE IDOtherMember=@.IDOtherMember

ORDERBY DepthDESC

|||

I changed the query from what I described above so that it won't allow circular paths (3700,3726,3700, etc) because they will never be "shortest", and also to reduce processing time.

I also implemented the MaxDepth differently. Instead of allowing the CTE to recurse completely and then filtering based on the depth, I terminate the recursion at the MaxDepth.

|||

hello to motly,

Thank you very much. With your help i have resolved this problem. Now i can quickly get a result. Thanks

Best Regard

Shasha

Sunday, February 19, 2012

Help: About ms sql query, how can i check if a part string exists in a string?

Hello to all,

I have a problem with ms sql query. I hope that somebody can help me.

i have a table "Relationships". There are two Fields (IDMember und RelationshipIDs) in this table. IDMember is the Owner ID (type: integer) und RelationshipIDs saves all partners of this Owner ( type: varchar(1000)). Example Datas for Table Relationships: IDMember Relationships .

3387 (2345, 2388,4567,...)

4567 (8990, 7865, 3387...)

i wirte a query to check if there is Relationship between two members.

Query:

Declare @.IDM int; Declare @.IDO int; Set @.IDM = 3387, @.IDO = 4567;

select *

from Relationship

where(IDMember= @.IDM)and( cast(@.ID0 as char(100)) in

(select Relationship.[RelationshipIDs]from Relationshipwhere IDMember= @.IDM))

But I get nothing by this query.

Can Someone tell me where is the problem? Thanks

Best Regards

Pinsha

Use the PATINDEX function to check if a one part is there in a string or not and you can write your query like this

Select * from RelationShip

Where (IDMember=@.IDM)

AND ( PATINDEX(@.IDO, RelationshipIDs) > 0 ) -- If the string is found this will return greater than 0 the starting of the string

This should help you

|||

try this, you have to tweak it a little to work correctly with small and big numbers ( like it will return 312 as connected to 12 but you can try to fix it your self for example by including separators between related ids)

createTable #Relationships

(IDMemberint,

Relationshipsvarchar(1000))

insertinto #Relationships

select' 3387','(2345, 2388,4567,...)'

insertinto #Relationships

select'4567','(8990, 7865, 3387...)'

Declare @.IDMint,

@.IDOint

Set @.IDM= 3387

SET @.IDO= 4567;

select*

from #Relationships

where(IDMember= @.IDM)and(charindex(cast(@.IDOasvarchar(100)),cast(Relationshipsasvarchar(1000)))>0)

droptable #Relationships

|||

Hello satya_tanwar,

i have tried to use the PATINDEX function, but if i used a variable in PATINDEX(@.IDO, RelationshipIDs) and (@.IDO = '3456', i doesn't work. If i use a constant in PATINDEX('3456', RelationshipIDs), it works.

I use ms sql 2005 to execute this query. Maybe can you tell me where is the problem?

Thank you very much

Best Regards

Pinsha

|||

Hallo japzgier,

I have also tried to use your example. But the variable incharindex function doesn't work. If i use constant incharindex function and it works.

i don't know whycharindex doesn't work with variable.

Maybe can you help me?

Thank you very much

Best Regards

Pinsha

|||

What is the variable type Pinsha...Could you please send the code to me coz i have tried to execute the query and its working. Whats result you are getting ?

or just try to modify the PatIndex part like this

(PATINDEX('%'+ @.IDO+'%', Relationships)> 0)

Will work for sure..

|||

I tested code I passed on my SQL server and I have no problems with it, I use SQL 2005 which version are you using?

|||

Hello to japzgier,

I found the straight problem. The problem is false data type. i habe defined a variable as char type and another variable as varchar type.

i use ms sql 2005.

Thanks very much

But i have now another problem, Maybe could you help me?

In my tablewtcomValidRelationships

IDMember RelationshipIDS

1 2

2 3

3 4

4 5

5 6

declare @.ENDPATH varchar(1000);

declare @.IDMint;

declare @.IDO varchar(100);

set @.IDM= 1;

set @.IDO='6'

declare @.Path3 varchar(1000);

set @.Path3=(selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)+'-'+convert(varchar(100),D.IDMember)+'-'+convert(varchar(100),E.IDMember)

from wtcomValidRelationshipsas A,

wtcomValidRelationshipsas B,

wtcomValidRelationshipsas C,

wtcomValidRelationshipsas D,

wtcomValidRelationshipsas E

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(convert(varchar(100),C.IDMember),B.RelationshipIDs)> 0

andcharindex(convert(varchar(100),D.IDMember), C.RelationshipIDs)> 0

andcharindex(convert(varchar(100),E.IDMember),D.RelationshipIDs)> 0

andcharindex(@.IDO,E.RelationshipIDs)> 0);

if(len(@.Path3)> 0)

begin

set @.ENDPATH= @.Path3;

end

else

begin

set @.ENDPATH='No Relationship';

end

print @.ENDPATH

Problem is that Query Excuting need to 38 Secends ?

Thanks

Best Regards

Pinsha

|||

Hi sasha,

Have you tried this

(PATINDEX('%'+ @.IDO+'%', Relationships)> 0)

|||

Hello satya,

i have tried this (PATINDEX('%'+ @.IDO+'%', Relationships)> 0) , it works. Thanks

but now i have another problem.

I need to search the relationships from level 1 to level 6.

so i need write aIF ELSE sql query. But when i useIF ELSE, the query excuting is too slow. without if else, the query excuting is rash.

But i must useIF ELSE to get my result. Maybe Could you tell me other methods, how can i check the first level query, if it has no elements and then go to excute next level , and continue do this compare. My complete Codes are here. I hope that you can understand what i mean. Because my english is poor . sorry

For Example

wtcomValidRelationships

IDMember RelationshipIDs

1 2

2 3

3 4

4 5

5 6

Without IF ELSE 5 select Query together excuted under 1 Seconds:

declare @.ENDPATH varchar(1000);

declare @.IDMint;

declare @.IDO varchar(100);

set @.IDM= 1;

set @.IDO='6'

select IDMember

from wtcomValidRelationships

where wtcomValidRelationships.[IDMember]= @.IDM

andPATINDEX('%'+@.IDO+'%',(select RelationshipIDsfrom wtcomValidRelationshipswhere IDMember= @.IDM))> 0

selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andPATINDEX('%'+@.IDO+'%',B.RelationshipIDs)> 0

selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B, wtcomValidRelationshipsas C

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(convert(varchar(100),C.IDMember),B.RelationshipIDs)> 0andPATINDEX('%'+@.IDO+'%',C.RelationshipIDs)> 0

selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)+'-'+convert(varchar(100),D.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B, wtcomValidRelationshipsas C, wtcomValidRelationshipsas D

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(convert(varchar(100),C.IDMember),B.RelationshipIDs)> 0andcharindex(convert(varchar(100),D.IDMember), C.RelationshipIDs)> 0

andPATINDEX('%'+@.IDO+'%',D.RelationshipIDs)> 0

selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)+'-'+convert(varchar(100),D.IDMember)+'-'+convert(varchar(100),E.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B, wtcomValidRelationshipsas C, wtcomValidRelationshipsas D, wtcomValidRelationshipsas E

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(convert(varchar(100),C.IDMember),B.RelationshipIDs)> 0andcharindex(convert(varchar(100),D.IDMember), C.RelationshipIDs)> 0

andcharindex(convert(varchar(100),E.IDMember),D.RelationshipIDs)> 0andPATINDEX('%'+@.IDO+'%',E.RelationshipIDs)> 0

But With IF ELSE query excuted more than 30 seconds

declare @.ENDPATH varchar(1000);

declare @.IDMint;

declare @.IDO varchar(100);

declare @.Level int;

set @.IDM= 3450;

set @.IDO='4269'

declare @.Path varchar(1000);

set @.Path='';

set @.Path=(select IDMember

from wtcomValidRelationships

where wtcomValidRelationships.[IDMember]= @.IDM

andcharindex( @.IDO,(select RelationshipIDsfrom wtcomValidRelationshipswhere IDMember= @.IDM))> 0);

if(len(@.Path)> 0)

begin

set @.ENDPATH= @.Path;

end

else

begin

declare @.Path1 varchar(1000);

set @.Path1=(selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(@.IDO,B.RelationshipIDs)> 0);

if(len(@.Path1)> 0)

begin

set @.ENDPATH= @.Path1;

end

else

begin

declare @.Path5 varchar(1000);

set @.Path5=(selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B, wtcomValidRelationshipsas C

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(convert(varchar(100),C.IDMember),B.RelationshipIDs)> 0andcharindex(@.IDO,C.RelationshipIDs)> 0);

if(len(@.Path5)> 0)

begin

set @.ENDPATH= @.Path5;

end

else

begin

declare @.Path2 varchar(1000);

set @.Path2=(selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)+'-'+convert(varchar(100),D.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B, wtcomValidRelationshipsas C, wtcomValidRelationshipsas D

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(convert(varchar(100),C.IDMember),B.RelationshipIDs)> 0andcharindex(convert(varchar(100),D.IDMember), C.RelationshipIDs)> 0

andcharindex(@.IDO,D.RelationshipIDs)> 0);

if(len(@.Path2)> 0)

begin

set @.ENDPATH= @.Path2;

end

else

begin

declare @.Path3 varchar(1000);

set @.Path3=(selecttop 1convert(varchar(100),A.IDMember)+'-'+convert(varchar(100),B.IDMember)+'-'+convert(varchar(100),C.IDMember)+'-'+convert(varchar(100),D.IDMember)+'-'+convert(varchar(100),E.IDMember)

from wtcomValidRelationshipsas A, wtcomValidRelationshipsas B, wtcomValidRelationshipsas C, wtcomValidRelationshipsas D, wtcomValidRelationshipsas E

where A.IDMember= @.IDMandcharindex(convert(varchar(100),B.IDMember),A.RelationshipIDS)> 0

andcharindex(convert(varchar(100),C.IDMember),B.RelationshipIDs)> 0andcharindex(convert(varchar(100),D.IDMember), C.RelationshipIDs)> 0

andcharindex(convert(varchar(100),E.IDMember),D.RelationshipIDs)> 0andcharindex(@.IDO,E.RelationshipIDs)> 0);

if(len(@.Path3)> 0)

begin

set @.ENDPATH= @.Path3;

end

else

begin

set @.ENDPATH='No Relationship'

end

end

end

end

end

print @.ENDPATH