Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SELECT uniquiID,
CountryFlag,
EventImage
,CONVERT(varchar(50), StartDate) as StartDate
,CONVERT(varchar(50), EndDate) as EndDate
,EventName
,Description
,CountryCode
,Remark
,Flag
FROM TradefairData <

What I have tried:

and my flag column value is - Null
0
1
Null
0
1

Then i Want to Know how to Use case when flag=1 then 3rd and 6th row invisible when flag=0 then all row visible else all row visible please help me
uniquiID is my uniqueId Column
Posted
Updated 9-May-17 23:52pm
v3
Comments
Maciej Los 10-May-17 2:08am    
Using clean T-SQL - you can't. It is possible to achieve programmatically.

Your question is not clear...

As i stated in the comment to the question, there's no such functionality to show/hide rows in clean T-SQL. The way to fetch all data and display only data which meets some criteria is to use reporting tools. But (!) if you want to fetch data with flag = 0 or null, you can use something like this:

SQL
SELECT *
FROM YourTableName
WHERE Flag = 0 OR Flag IS NULL


For further details, please see:
WHERE (Transact-SQL) | Microsoft Docs[^]
SELECT Examples (Transact-SQL) | Microsoft Docs[^]
SELECT (Transact-SQL) | Microsoft Docs[^]
 
Share this answer
 
v2
Here is where flag is 1 then show record who have flag 1 and flag 0 show record who have flag 0 and nothing to pass in flag then show all value


SQL
Declare @flag bit

if(@flag !=0 or @flag !=1 )
begin
	SELECT uniquiID,CountryFlag,EventImage,CONVERT(varchar(50), StartDate) as StartDate
	,CONVERT(varchar(50), EndDate) as EndDate,EventName,Description,CountryCode,Remark,Flag
	FROM TradefairData 
end
else
begin
	SELECT uniquiID,CountryFlag,EventImage,CONVERT(varchar(50), StartDate) as StartDate
	,CONVERT(varchar(50), EndDate) as EndDate,EventName,Description,CountryCode,Remark,Flag
	FROM TradefairData where flag=@flage
end
 
Share this answer
 
Comments
Member 12183079 10-May-17 2:24am    
no i am trying to do when flag=1 then only one row invisible nor all

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900