Problem: the upper-level organization wants to check the data. The database on my server is SQL server 2000, and the upper-level organization requires me to use SQL statements to randomly query 50 pieces of data on the server. However, some error data on my server is not expected to be seen by them. Is there any way to prevent them from seeing it.
SQL statement: select top 50 x from a_1 where c = xxxx
The statement must be written in this way and then run it. What should I do? How can I set it on SQL server, then, the 50 pieces of data are randomly queried only from the data I found (for example, 400 of the correct data. Try not to change the SQL statement.
Peak Wong:
Available View:
When the recipient extracts:
Select top 50 * from t_view -- View name
Order by newID ()
Exclude non-displayed views when generating them. When a view is queried, it is also a table name method // as long as the other party does not know the database table.
SQL code
Copy codeThe Code is as follows:
Select top 10 ID, Name
Into T -- Generate Test Table
From sysobjects
Go
Create view Test -- generate view name
As
Select * from T where ID> 5
Go
Select top 2 * from test order by newID () -- two random values are obtained.
Note: The view name should be similar to the table name. Create view Test -- generate view name
With ENCRYPTION -- encrypt the statement so that the recipient cannot see your view statement.
As
Select * from T where ID> 5
Go
This article comes from the webmaster Information Network Original article link: http://sqlserver.chinahtml.com/2007/119613367717217.shtml