Select Random Rows from Table in SQL Server

To Select 1 Random Records from a table in SQL Server   SELECT TOP 1 * FROM Table_Name ORDER BY NEWID() ;   To Select 10 Random Records from a table in SQL Server   SELECT TOP 10 * FROM tAudit ORDER BY NEWID()

Advertisements

Check for Listening Port SQL Server

DECLARE @tcp_port nvarchar(5) EXEC xp_regread @rootkey = 'HKEY_LOCAL_MACHINE', @key = 'SOFTWARE\MICROSOFT\MSSQLSERVER\MSSQLSERVER\SUPERSOCKETNETLIB\TCP', @value_name = 'TcpPort', @value = @tcp_port OUTPUT select @tcp_port

Create Snapshot on Mirror Database SQL Server 2008

Create snapshot on mirror database Sql Server 2008 -- Run below command to find logical filename of database against which you creating a mirror select name, type_desc, physical_name from sys.master_files where database_id = db_id('QIIB_MSCRM') mscrm ROWS C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\QIIB_MSCRM.mdf mscrm_log LOG C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\QIIB_MSCRM_log.LDF -- mscrm is name of file. Now go ahead … Continue reading Create Snapshot on Mirror Database SQL Server 2008