SQL Server – use a parameter to select the top X of the result set [duplicate]

In SqlServer 2005 and up, do this: CREATE PROCEDURE GetResults ( @ResultCount int ) AS SELECT top(@ResultCount) FROM table where x = y For earlier versions, use: CREATE PROCEDURE GetResults ( @ResultCount int ) AS SET ROWCOUNT @ResultCount SELECT * FROM table where x = y https://web.archive.org/web/20210417081325/http://www.4guysfromrolla.com/webtech/070605-1.shtml for more information.

SQL Server Agent Job Notify multiple operators on failure

Question: Is it possible to setup a notification email being sent to multiple operators for that specific job? I don’t believe this is possible. Certainly looking at the structure of [msdb].[dbo].[sysjobs] the various operator_id columns are in this table itself which would support the idea that 1 to many is not possible. But some alternatives … Read more

What is the meaning of the following SQL Server declaration: datetime2(7)?

datetime2 [ (fractional seconds precision) ] It’s the fractional seconds precision according to the MSDN documentation. http://msdn.microsoft.com/en-us/library/bb677335.aspx This is the microsoft example of 4: DECLARE @datetime2 datetime2(4) = ’12-10-25 12:32:10.1234′; So I would assume that 7 would be: DECLARE @datetime2 datetime2(7) = ’12-10-25 12:32:10.1234567′;