
Untitled
By: a guest on
Jul 15th, 2012 | syntax:
None | size: 0.57 KB | hits: 14 | expires: Never
Retrieving value from EXEC(@sql)
SELECT top (value) field, field2 FROM table
SELECT @first = min(field2) FROM (SELECT top (value) field, field2 FROM table)
DECLARE @RowCount int -- =25 -- sql server 2008 allows to assign when declaring
SELECT @RowCount = 25
SELECT TOP (@RowCount) * FROM table1
DECLARE @RowCount int
SELECT @RowCount = 25
SET ROWCOUNT @RowCount
SELECT * FROM table1
SET ROWCOUNT 0 -- make sure to set back to 0 otherwise
-- queries below will return 25 rows
declare @top int = 10
select top (@top) field, field2 from table