working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,917 snippets matching: physical

    public by cghersi  1942  0  6  0

    Finding actual number of physical cpu installed

    By Rahul Singh, 2013/01/14 The Sql Server always see Logical cpu it does not distinguish between Hyperthreaded logical cpu and physical processor using the below query we can find out actual number of physical cpu installed on the server The first column represent logical processor and second column represent actual physical processor insta
    SELECT cpu_count AS Logical_CPU_Count , cpu_count / hyperthread_ratio AS Physical_CPU_Count FROM sys.dm_os_sys_info ;

    public by cghersi  4309  6  6  2

    Move a file to another location in SQL Server

    Here is the procedure to move a file to another location (e.g. for the database called MyDB). First you need to execute the first part of this snippet (until the comment '/**** Now you need to physically move the file to the other location ***/'). Then you need to move the file and eventually you can execute the last two statements.
    ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
    
    ALTER DATABASE MyDB SET OFFLINE;
    
    ALTER DATABASE MyDB MODIFY FILE 
    (
       Name = MyDB_file1,
       Filename = 'c:\DB\MyDB.mdf'
    );
    
    /**** Now you need to physically move the file to the other location ***/
    
    ALTER DATABASE MyDB SET ONLINE;
    
    ALTER DATABASE MyDB SET MULTI_USER;

    public by lbottaro  2675  8  6  2

    How to detect your computer's RAM configuration via cmd prompt

    Using this simple WMI (Windows Management Instrumentation) command you can see how your RAM is configured on your pc. The output shows how many banks are used and their capacity. Output: Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\wmic MEMORYCHIP get banklabel, devicelocator, caption, capaci
    C:\>wmic MEMORYCHIP get banklabel, devicelocator, caption, capacity

    public by cghersi  3373  3  6  4

    Change the location of MS SQL Server database files

    When you start playing with serious DB, one of the most important parts is to place (if possible) the files in different drives (physical, not only logical partitions!!!). But what if you already have your DB in production with tons of data on the same location? This script helps in solving the issue. It should be executed in three steps: 1) p
    -- 1) Execute this first chunk to put the DB offline
    ALTER DATABASE MyDBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
    ALTER DATABASE MyDBName SET OFFLINE;
    ALTER DATABASE MyDBName MODIFY FILE 
    (
       Name = MyDBName_Data,
       Filename = 'D:\DB\MyDBName.mdf'
    );
    
    ALTER DATABASE MyDBName MODIFY FILE 
    (
       Name = MyDBName_Log, 
       Filename = 'D:\DBLog\MyDBName_log.ldf'
    );
    
    ALTER DATABASE MyDBName MODIFY FILE 
    (
       Name = MyDBName_Idx, 
       Filename = 'E:\DBIndex\MyDBName_log.ndf'
    );
    
    -- 2) Manually move the files in the right location
    
    -- 3) Execute this second chunk to put the DB online
    ALTER DATABASE my SET ONLINE;
    
    ALTER DATABASE my SET MULTI_USER;

    public by cghersi  3272  1  5  0

    BATCH MS-DOS: Simulate network disconnection

    This command can be used to simulate a broken network connection towards a particular IP. In the example, 10.0.2.4 is the IP that we want to break the connection with; 10.0.3.52 is another IP of a physical machine present in the LAN.
    rem break the connection
    route add 10.0.2.4 mask 255.255.255.255 10.0.3.52
    
    rem re-establish the connection
    route delete 10.0.2.4

    public by qxshower  1472  1  4  0

    IsPhysicalFile

    Determines if the specified project item is a physical file.
    using EnvDTE;
    using System;
    using System.Linq;
    
    /// <summary>
    /// Determines if the specified project item is a physical file.
    /// </summary>
    /// <param name="projectItem">The project item.</param>
    /// <returns>True if the project item is a physical file, otherwise false.</returns>
    internal static bool IsPhysicalFile(this ProjectItem projectItem)
    {
        try
        {
            return string.Equals(projectItem.Kind, Constants.vsProjectItemKindPhysicalFile, StringComparison.OrdinalIgnoreCase);
        }
        catch (Exception ex)
        {
            // Some ProjectItem types (e.g. WiX) may throw an error when accessing the Kind member.
            OutputWindowHelper.ExceptionWriteLine("Unable to determine if ProjectItem is a physical file", ex);
            return false;
        }
    }            

    public by msdn  2781  3  6  0

    CreateVirtualHardDisk: Creates a VHD or VHDX.

    Creates a VHD or VHDX. The name of the server on which to perform the action. The path to the VHD/VHDX to create. The path to the parent VHD/VHDX. The type for the new VHD/VHDX. The format of the new VHD/VHDX. The size of the new VHD/VHDX. The block size of the new VHD/VHDX. The logical sector size of the new VHD/VHDX. The physical sec
    /// <summary>
    /// Creates a VHD or VHDX.
    /// </summary>
    /// <param name="ServerName">The name of the server on which to perform the action.</param>
    /// <param name="VirtualHardDiskPath">The path to the VHD/VHDX to create.</param>
    /// <param name="ParentPath">The path to the parent VHD/VHDX.</param>
    /// <param name="Type">The type for the new VHD/VHDX.</param>
    /// <param name="Format">The format of the new VHD/VHDX.</param>
    /// <param name="FileSize">The size of the new VHD/VHDX.</param>
    /// <param name="BlockSize">The block size of the new VHD/VHDX.</param>
    /// <param name="LogicalSectorSize">The logical sector size of the new VHD/VHDX.</param>
    /// <param name="PhysicalSectorSize">The physical sector size of the new VHD/VHDX.</param>
    internal static void
    CreateVirtualHardDisk(
        string ServerName,
        string VirtualHardDiskPath,
        string ParentPath,
        VirtualHardDiskType Type,
        VirtualHardDiskFormat Format,
        Int64 FileSize,
        Int32 BlockSize,
        Int32 LogicalSectorSize,
        Int32 PhysicalSectorSize)
    {
        ManagementScope scope =
            new ManagementScope("\\\\" + ServerName + "\\root\\virtualization\\v2");
    
        VirtualHardDiskSettingData settingData =
            new VirtualHardDiskSettingData(
                Type,
                Format,
                VirtualHardDiskPath,
                ParentPath,
                FileSize,
                BlockSize,
                LogicalSectorSize,
                PhysicalSectorSize);
    
        using (ManagementObject imageManagementService =
            StorageUtilities.GetImageManagementService(scope))
        {
            using (ManagementBaseObject inParams =
                imageManagementService.GetMethodParameters("CreateVirtualHardDisk"))
            {
                inParams["VirtualDiskSettingData"] =
                    settingData.GetVirtualHardDiskSettingDataEmbeddedInstance(
                        ServerName,
                        imageManagementService.Path.Path);
    
                using (ManagementBaseObject outParams = imageManagementService.InvokeMethod(
                    "CreateVirtualHardDisk", inParams, null))
                {
                    WmiUtilities.ValidateOutput(outParams, scope);
                }
            }
        }
    }

    public by msdn  1439  1  6  0

    SetVirtualHardDisk: Sets various settings on a VHD/VHDX.

    Sets various settings on a VHD/VHDX. The name of the server on which to perform the action. The path to the VHD/VHDX. The new path to the parent VHD/VHDX. The new physical sector size of the VHDX. Setting the physical sector size is only supported on VHDX.
    /// <summary>
    /// Sets various settings on a VHD/VHDX.
    /// </summary>
    /// <param name="ServerName">The name of the server on which to perform the action.</param>
    /// <param name="VirtualHardDiskPath">The path to the VHD/VHDX.</param>
    /// <param name="ParentPath">The new path to the parent VHD/VHDX.</param>
    /// <param name="PhysicalSectorSize">The new physical sector size of the VHDX.  Setting the
    /// physical sector size is only supported on VHDX.</param>
    internal static void
    SetVirtualHardDisk(
        string ServerName,
        string VirtualHardDiskPath,
        string ParentPath,
        Int32 PhysicalSectorSize)
    {
        ManagementScope scope =
            new ManagementScope("\\\\" + ServerName + "\\root\\virtualization\\v2");
    
        VirtualHardDiskSettingData settingData =
            new VirtualHardDiskSettingData(
                VirtualHardDiskType.Unknown,
                VirtualHardDiskFormat.Unknown,
                VirtualHardDiskPath,
                ParentPath,
                0,
                0,
                0,
                PhysicalSectorSize);
    
        using (ManagementObject imageManagementService =
            StorageUtilities.GetImageManagementService(scope))
        {
            using (ManagementBaseObject inParams =
                imageManagementService.GetMethodParameters("SetVirtualHardDiskSettingData"))
            {                    
                inParams["VirtualDiskSettingData"] =
                    settingData.GetVirtualHardDiskSettingDataEmbeddedInstance(
                        ServerName,
                        imageManagementService.Path.Path);
    
                using (ManagementBaseObject outParams = imageManagementService.InvokeMethod(
                    "SetVirtualHardDiskSettingData", inParams, null))
                {
                    WmiUtilities.ValidateOutput(outParams, scope);
                }
            }
        }
    }

    public by msdn  1259  0  6  0

    GetWebPathFromSolutionPath: Returns a WebPath assuming that the name of the Web directory is the same as the solution name

    Returns a WebPath assuming that the name of the Web directory is the same as the solution name Physical path to the web application
    /// <summary>
    ///   Returns a WebPath assuming that the name of the Web directory is the same
    ///   as the solution name
    /// </summary>
    /// <param name = "testContextInstance"></param>
    /// <returns>Physical path to the web application</returns>
    public static string GetWebPathFromSolutionPath(TestContext testContextInstance)
    {
        var solutionPath = GetSolutionPath(testContextInstance);
        var segments = solutionPath.Split('\\');
    
        if (segments.Length - 2 < 0)
        {
            throw new InvalidOperationException(string.Format("Cannot extract solution name from solution path \"{0}\"", solutionPath));
        }
    
        var solutionName = segments[segments.Length - 2];
        return solutionPath + solutionName;
    }

    public by msdn  955  0  6  0

    GetWebPathFromSolutionPath: Returns a WebPath assuming that the name of the Web directory is the same as the solution name

    Returns a WebPath assuming that the name of the Web directory is the same as the solution name Physical path to the web application
    using System;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Threading;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    
    /// <summary>
    /// Returns a WebPath assuming that the name of the Web directory is the same
    /// as the solution name
    /// </summary>
    /// <param name="testContextInstance"></param>
    /// <returns>Physical path to the web application</returns>
    public static string GetWebPathFromSolutionPath(TestContext testContextInstance)
    {
        string solutionPath = GetSolutionPath(testContextInstance);
        string[] segments = solutionPath.Split('\\');
    
        if (segments.Length - 2 < 0)
            throw new InvalidOperationException(string.Format("Cannot extract solution name from solution path \"{0}\"", solutionPath));
    
        string solutionName = segments[segments.Length - 2];
        return solutionPath + solutionName;
    }
    • Public Snippets
    • Channels Snippets