Is is often useful when You work with databases to see the sample of the data, in order to understand the meaning of these data and the meaning of the table.
One of the way to understood the table (entity) is to see which columns(attributes) he has. Standard way to do that is to execute following query:
SELECT * FROM Person.Person WHERE 1 = 0
As a result of that query, You are going to get a list o table attributes.
From SQL Server 2005, there is a feature which gives user sample of the table data, through which user can understand that table (and entity it describes) better. SQL query which gives You sample data is:
SELECT FirstName,LastName
FROM Person.Person TABLESAMPLE (1 PERCENT)
In a case of AdventureWorks2008R2 database, as a result of that SQL statement You get the result with 170, 355, 389...results. So it means that resultset is not static and it changes.
Also, it is possible to run TABLESAMPLE command with approximate number of rows which should be returned in recordset:
SELECT FirstName, LastName
FROM Person.Person TABLESAMPLE (100 ROWS) ;
One of the way to understood the table (entity) is to see which columns(attributes) he has. Standard way to do that is to execute following query:
SELECT * FROM Person.Person WHERE 1 = 0
As a result of that query, You are going to get a list o table attributes.
From SQL Server 2005, there is a feature which gives user sample of the table data, through which user can understand that table (and entity it describes) better. SQL query which gives You sample data is:
SELECT FirstName,LastName
FROM Person.Person TABLESAMPLE (1 PERCENT)
In a case of AdventureWorks2008R2 database, as a result of that SQL statement You get the result with 170, 355, 389...results. So it means that resultset is not static and it changes.
Also, it is possible to run TABLESAMPLE command with approximate number of rows which should be returned in recordset:
SELECT FirstName, LastName
FROM Person.Person TABLESAMPLE (100 ROWS) ;
No comments:
Post a Comment