Storing SQL queries in Table in sql server

Posted by Rohit on Stack Overflow See other posts from Stack Overflow or by Rohit
Published on 2010-05-26T06:06:09Z Indexed on 2010/05/26 6:11 UTC
Read the original article Hit count: 242

Filed under:
|
|

We have multiple jobs in our system.These jobs are listed in a grid. We have 3 different user types (usertypeid 1,2,3). For each user listing is different and he can filter listing by selecting view from a dropdown. ViewName in the below table is the view which needs to be displayed. To achieve this functionality, a fellow developer has created the following table structure and stored sql fragments in SQLExpression in the below table. According to me the query should not be stored in database. What are the pros and cons of this approach and what are the available alternatives?

JobListingViewID         ViewName        SQLExpression            UserTypeID
 3                     All Jobs            1 = 1                       3
 4                     Error Jobs   JobStatusID IN ( 2 )               1
 5                     Error Jobs   JobStatusID IN ( 2 )               2
 6                     Error Jobs   JobStatusID IN ( 2 )               3
 7                     Speech       JobStatusID IN ( 1, 3, 8 )         1

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005