Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3619464
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:52:53+00:00 2026-05-18T22:52:53+00:00

hi suppos I have this table’s fields : Employees id , firstname , lastname

  • 0

hi suppos I have this table’s fields : Employees

id , firstname , lastname , birthdate

and I want to make privacy on some fields so I created this table containing these fields

tableName, ColumnName , PrivacyType [Visible/Notvisible]

and when Selecting a row from the first table I don’t want to get the fields that have
privacy type = NotVisible

any idea

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:52:54+00:00Added an answer on May 18, 2026 at 10:52 pm

    Generally, if you need some columns/rows hidden from a (set of) users, you’d implement a view for them. You’d then deny SELECT on the base table. The view definition would only reference those columns that you want to make accessible to the group of users you grant SELECT on the view to.

    Once you have access going via views, as I say, you can implement more complex requirements, such as row level security.

    (You can do something ugly in your views, if you’re set on having the privacy settings change dynamically, but I wouldn’t recommend it):

    create table dbo.T1 (
        ID int not null,
        Col1 varchar(10) not null,
        Col2 varchar(10) not null,
        Col3 varchar(10) not null
    )
    go
    create table dbo.Privacy (
        Schemaname sysname not null,
        Tablename sysname not null,
        Columnname sysname not null,
        Hidden bit not null
    )
    go
    insert into dbo.T1 (ID,Col1,Col2,Col3)
    select 1,'abc','def','ghi' union all
    select 2,'ZYX','WVU','TSR'
    go
    insert into dbo.Privacy (Schemaname,Tablename,Columnname,Hidden)
    select 'dbo','T1','Col2',1
    go
    create function dbo.ShowColumn (
        @Schema sysname,
        @Table sysname,
        @Column sysname
    )
    returns int
    as
    begin
        if exists(select * from dbo.Privacy where Schemaname = @Schema and Tablename = @Table and Columnname = @Column and Hidden=1)
        begin
            return 0
        end
        return 1
    end
    go
    create view dbo.Virtual_T1 (ID,Col1,Col2,Col3)
    as
        select
            ID,
            CASE WHEN 1 = dbo.ShowColumn('dbo','T1','Col1') THEN Col1 ELSE '' END,
            CASE WHEN 1 = dbo.ShowColumn('dbo','T1','Col2') THEN Col2 ELSE '' END,
            CASE WHEN 1 = dbo.ShowColumn('dbo','T1','Col3') THEN Col3 ELSE '' END
        from
            dbo.T1
    go
    select * from dbo.Virtual_T1
    

    Result:

    ID  Col1    Col2    Col3
    1    abc             ghi
    2    ZYX             TSR
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose I have this table var 10 3 4 60 70 and I want
I have a table name wishlist . In this I have two fields user_id
Suppose I have this database table (some sample code below) that stores the relationship
Suppose i have this table table (a,b,c,d). Datatypes are not important. I want to
Suppose we have a table with collumns (A,B,C) We want to search this table
Suppose I have a table view, and I want to implement something like this:
Suppose you have a table like this: id user score It's a dump of
Suppose I have this feature branch foo. Now I want to merge it back
suppose I have this table id | cash 1 200 2 301 3 101
Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.