Friday, February 23, 2024

How can one address the collation discrepancy that arises when the database and the table have different collations?

If you want to change the collation of the entire database, you can use the following command:

ALTER DATABASE YourDatabaseName

COLLATE NewCollationName

Replace "YourDatabaseName" with the name of your database and "NewCollationName" with the name of the collation you want to use.

Remember, changing the collation of a database will only affect the default collation of new tables and columns and won’t change the collation of existing tables and columns. You would need to change those individually if needed.

You can alter the collation of a specific column in a table using the ALTER TABLE statement. Here is a general example:

ALTER TABLE YourTableName

ALTER COLUMN YourColumnName

COLLATE NewCollationName

In this query, replace "YourTableName" with the name of your table, "YourColumnName" with the name of the column that has the collation issue, and "NewCollationName" with the name of the collation you want to use.

Please note that you should be careful when changing collation as it can affect your data and the performance of your queries. It’s recommended to back up your data before making such changes. Also, ensure that the new collation is compatible with your data.

Thursday, September 7, 2023

Step-by-Step Guide to Updating Env Config Variables in Octopus Project

Step-by-Step Guide to Updating Env Config Variables in Octopus Project -

  1. Open the Octopus project for which you want to update the Env Config variables.

  2. In the left-hand navigation pane, click Variables > Project Templates.

  3. Add the required project templates along with their values.

  4. Click Save.

  5. Click Tenants from the menu.

  6. Select the required tenant.

  7. Click Variables.

  8. Expand the required project to update the variable names.

  9. Update the variables and click Save.

  10. Return to the Octopus project.

  11. Click Process.

  12. Add the Octopus Admin and Service Fabric modules from the Script Modules section.

  13. Click the Add step (Run a script).

Test Env Config file:

hostname = hostname_value

Use the following PowerShell script to update the Env Config variables:

#Test [String]$hostname = "" Write-Message -Message ("Validating Test Variables ....") ##Validate Test Variables For Successful Deployment

$hostname = Validate-SFParameters -Value $OctopusParameters['hostname'] -ParameterName "hostname" -ReturnValue Write-Header -Header "END VALIDATING VARIABLES"; ## -------------------------------------------------------------------------------------- ## Update the variables in the Config file ## -------------------------------------------------------------------------------------- $config_file_path = "C:\config\default.config" # Open the config file $config_file = Get-Content -Path $config_file_path $config_file = $config_file -replace "(?<=^|\W)hostname_value(?=\W|$)", $hostname # Write the config file Set-Content $config_file_path $config_file

14. Create the release

15. Open the test environment configuration file in the project directory and verify that the configurations have been updated.

Friday, July 28, 2023

Number System Conversions

This blog post covers various number system conversions, explaining how to convert numbers between decimal, octal, hexadecimal, and binary representations. The content presents step-by-step procedures for each conversion, making it easy for readers to follow along.

1) Decimal to Octal:

231

231 ÷ 8 = 28

231 % 8 = 7

28 ÷ 8 = 3

28 % 8 = 4

3 ÷ 8 = 0

3 % 8 = 3

So, the octal equivalent of the decimal number 231 is 347.

Octal to Decimal
347

3 * 8^2 + 4 * 8^1 + 7 * 8^0
3 * 64 + 4 * 8 + 7 * 1
192 + 32 + 7 = 231

So, the decimal equivalent of the octal number 347 is 231.

2) Decimal to Hexadecimal
200

200 ÷ 16 = 12
200 % 16 = 8

12 ÷ 16 = 0
12 % 16 = 12 (C)
So, the hexadecimal equivalent of the decimal number 200 is C8.

Hexadecimal to Decimal
C8

C * 16^1 + 8 * 16^0

12 * 16 + 8 * 1
192 + 8 = 200
So, the decimal equivalent of hexadecimal number C8 is 200.

3) Decimal to Binary
125

125 ÷ 2 = 62
125 % 2 = 1

62 ÷ 2 = 31
62 % 2 = 0

31 ÷ 2 = 15
31 % 2 = 1

15 ÷ 2 = 7
15 % 2 = 1

7 ÷ 2 = 3
7 % 2 = 1

3 ÷ 2 = 1
3 % 2 = 1

1 ÷ 2 = 0
1 % 2 = 1
So, the binary equivalent of the decimal number 125 is 1111101.

Binary to Decimal
1111101

= (1 * 2^6) + (1 * 2^5) + (1 * 2^4) + (1 * 2^3) + (1 * 2^2) + (0 * 2^1) + (1 * 2^0)
= 64 + 32 + 16 + 8 + 4 + 0 + 1
= 125

So, the decimal equivalent of the binary number 1111101 is 125.


Thursday, March 9, 2023

To find out the space used by tables in MS SQL Server

Use the below code to find out the space used by tables in MS SQL Server -


SELECT 
    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS FreeSpaceKB,
    CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS FreeSpaceMB
FROM 
    sys.tables t
INNER JOIN     
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN 
    sys.schemas s ON t.schema_id = s.schema_id
WHERE 
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
GROUP BY 
    t.Name, s.Name, p.Rows
ORDER BY 
    TotalSpaceMB DESC


Wednesday, March 8, 2023

How to publish artifacts in Azure DevOps pipeline

Everyone is interested in viewing the artifacts, such as logs and execution reports after the pipeline execution is complete.

Use the following lines of code in the YAML file to upload the artifacts after the execution.

$(System.DefaultWorkingDirectory) -- is the current project directory

-   taskPublishBuildArtifacts@1
        conditionalways()
        inputs:
            pathToPublish$(System.DefaultWorkingDirectory)\logs
            artifactNameYour artifact name
        displayNameprovide your display name

Monday, February 20, 2023

How to Zoom In, Zoom Out the Chrome, Edge, Safari and Firefox Browsers

 How to Zoom In, Zoom Out the Chrome, Edge, Safari and Firefox Browsers -


We can zoom in, and zoom out the browsers by using the following commands -

"document.body.style.zoom = 'number of % to zoom'";

document.body.style.MozTransform = 'scale(number of % to zoom)';";


public class Tests{

public static void main(String[] args){

WebDriver driver=new ChromeDriver();

driver.get("https://software-testing-made-lifeeasy.blogspot.com/");

JavascriptExecutor js = (JavascriptExecutor)driver;

//The below line will work for these browsers - Chrome, Edge and Safari

String zoomProperty = "document.body.style.zoom = '200.0%'";

//The below line will work only for the Firefox browser

String zoomProperty = "document.body.style.MozTransform = 'scale(0.5)';"; //50% zoom, If you provide scale as 1, it's 100% zoom.

js.executeScript(zoomProperty);

}

}

Thursday, August 4, 2022

How to rename a database in the MS SQL server:


Use the below code to rename a database in the MS SQL server - 

USE master; GO ALTER DATABASE Database01 SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE Database01 MODIFY NAME = Database02 ; GO ALTER DATABASE Database02 SET MULTI_USER GO