When we want to comment out some code in specific condition, we can use #if and #endif in C# instead of comment and uncomment things.
#if Local
do something1
#endif
#if Test
do something2
#endif
If you want to enable do something1 and do something2:
Under Project -> your project property
Build tab -> Conditional compilation symbols: Local; Test
Enable the modes separated by semicolon.
Thursday, July 23, 2015
Wednesday, July 1, 2015
Hide/Unhide Table in Microsoft SQL
Part 1: Hide A Table
Suppose you want to hide a table which has important items that you don't want others to see from SQL Server Management Studio, but still want to use the data within this table, like select something from it as normal, you can run the following query:
use Test; --Database name
EXEC sp_addextendedproperty
@name = N'microsoft_database_tools_support',
@value = '<Hide? , sysname, 1>',
@level0type ='schema',
@level0name ='dbo', --give the schema name here. if it is dbo give 'dbo'
@level1type = 'table',
@level1name = 'Meeting' --give the table name which you want to hide.
In this example, I hide the "dbo.Meeting" table in database Test.
By running the above, table dbo.Meeting will be listed under System Tables subfolder.
But I can still use select * from dbo.Meeting to get the data from table Meeting.
Another more simple way of doing this is to modify the property of the Table:
1. right click on the table you want to hide
2. select Properties
3.In Table Properties window, select Extended Properties
Add a new entry with
Name: microsoft_database_tools_support
Value: <Hide? , sysname, 1>
Click OK
4. Refresh the Table,
You will see Table Meeting is under System Tables.
Part 2: Unhide A Table
Do the same thing as 1 and 2 in part one.
Delete the Extended Properties we just added.
The table will come back to the original place.
Suppose you want to hide a table which has important items that you don't want others to see from SQL Server Management Studio, but still want to use the data within this table, like select something from it as normal, you can run the following query:
use Test; --Database name
EXEC sp_addextendedproperty
@name = N'microsoft_database_tools_support',
@value = '<Hide? , sysname, 1>',
@level0type ='schema',
@level0name ='dbo', --give the schema name here. if it is dbo give 'dbo'
@level1type = 'table',
@level1name = 'Meeting' --give the table name which you want to hide.
In this example, I hide the "dbo.Meeting" table in database Test.
By running the above, table dbo.Meeting will be listed under System Tables subfolder.
But I can still use select * from dbo.Meeting to get the data from table Meeting.
Another more simple way of doing this is to modify the property of the Table:
1. right click on the table you want to hide
2. select Properties
3.In Table Properties window, select Extended Properties
Add a new entry with
Name: microsoft_database_tools_support
Value: <Hide? , sysname, 1>
Click OK
4. Refresh the Table,
You will see Table Meeting is under System Tables.
Part 2: Unhide A Table
Do the same thing as 1 and 2 in part one.
Delete the Extended Properties we just added.
The table will come back to the original place.
Subscribe to:
Comments (Atom)


