How to use SQL statements to randomly query data without displaying Error Data

Source: Internet
Author: User
Tags how to use sql
How to use SQL statements to randomly query data without displaying Error Data

How to use SQL statements to randomly query data without displaying Error Data

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

The 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.