Wednesday, November 16, 2011

SQL Server CPU, Memory count query

SQL 2005
USE [master];
GO
select
    cpu_count
,    hyperthread_ratio
,    physical_memory_in_bytes / 1048576 as 'mem_MB'
,    virtual_memory_in_bytes / 1048576 as 'virtual_mem_MB'
,    max_workers_count
,    os_error_mode
,    os_priority_class
from
    sys.dm_os_sys_info

xp_cmdshell Copy file path space error/issue on SQL Server

Using  xp_cmdshell , copy file on SQL Server have an folder name issue.

Example:
Wrong one:  xp_cmdshell 'copy  C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.mdf  d:\temp'

Error: The above command will fail to execute it due to the folder naming convention and the spaces between folder names.(ex.Program Files  and Microsoft SQL Server). So the solution for this is just put full path on  double quote(") start and end.Then it works fine.


Correct one:  xp_cmdshell 'copy "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.mdf" d:\temp'