Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Fetching values under condition Expand / Collapse
Author
Message
Posted Saturday, September 8, 2012 3:26 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 25, 2015 11:19 AM
Points: 13, Visits: 64
Hi to all I have a Query which is fix like

SELECT StudentId,EnrolmentId,SessionId,SchoolId, Name, ClassGroupId, ClassId, ClassName FROM ViewStudentTable WHERE IsBlock = 0 and sessionid=11 and schoolid=1 and classid=2

I am searching student under session 11 schoolid 1 and classid 2

Output is fine

But now People searching student under session 11 and in schoolid=1

I don't want to change query i wants that output should come with the same query
Post #1356351
Posted Saturday, September 8, 2012 5:42 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, August 13, 2015 9:13 AM
Points: 35, Visits: 168
Once you prefer different outputs, obviously you need to change the filtering. But, i don't know what is the problem of changing the query..

Regards,
Karthik.
SQL Developer.
Post #1356361
Posted Sunday, September 9, 2012 10:55 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:09 PM
Points: 38,338, Visits: 35,255
goldyabk1 (9/8/2012)
Hi to all I have a Query which is fix like

SELECT StudentId,EnrolmentId,SessionId,SchoolId, Name, ClassGroupId, ClassId, ClassName FROM ViewStudentTable WHERE IsBlock = 0 and sessionid=11 and schoolid=1 and classid=2

I am searching student under session 11 schoolid 1 and classid 2

Output is fine

But now People searching student under session 11 and in schoolid=1

I don't want to change query i wants that output should come with the same query

Create a stored procedure that contains the parameters you want to search for as variables.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1356554
Posted Monday, September 10, 2012 6:17 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, August 25, 2015 10:07 AM
Points: 27, Visits: 181
If you use stored procedure still you need to change the query. So, it is better to change the query directly. without changing the query you can't change the output.
Post #1356684
Posted Tuesday, September 11, 2012 3:45 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 25, 2015 11:19 AM
Points: 13, Visits: 64
Thanks
Post #1357243
Posted Tuesday, September 11, 2012 3:45 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, May 25, 2015 11:19 AM
Points: 13, Visits: 64
Thanks I got it
Post #1357244
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse