HI,
I have a table which has hundreds column which are boolean value.

I need select from the table based on passing parameter which column, (will set this column value = true)

How i write a store procedure which accept the column name as parameter, then based on this to get data?

Appreciate

Is this for academic purposes? If so, this is the quickest way. How you use it, though, can be vulnerable to SQL injections.

CREATE PROCEDURE GetValue ( @ColumnName VARCHAR(50) ) AS 
BEGIN  
  EXECUTE( 'select ' + @ColumnName + ' from Addresses' )
END 

GetValue @ColumnName = 'Zipcode'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.