Friday, 7 March 2025

L&TInterview

 

Difference Between VARCHAR and NVARCHAR in SQL Server

When to Use What?

  • Use VARCHAR when dealing with English or Latin-based languages (saves storage and improves performance).
  • Use NVARCHAR when storing multilingual data (Unicode characters like Chinese, Arabic, etc.).
FeatureVARCHARNVARCHAR
Storage TypeNon-UnicodeUnicode (UTF-16)
Character SupportOnly supports single-byte characters (e.g., English, Latin)Supports multilingual characters (e.g., Chinese, Arabic, Hindi)
Storage Size1 byte per character2 bytes per character (due to Unicode)
Prefix for String LiteralsNo prefix neededPrefix N before string (e.g., N'Text')
Max LengthVARCHAR(8000) or VARCHAR(MAX)NVARCHAR(4000) or NVARCHAR(MAX)
PerformanceFaster for English/Latin-based data (requires less storage)Slightly slower due to Unicode support
Best Use CaseEnglish, simple character setsMultilingual applications, special characters




L&T interview

1:Remove duplicates and spaces L&T 
2:fetch and pull
3:types of memories
4:try catch implimentations
5:var and nvarchar
6:entity ado major difference
7:localization in sql(for lanaguage specific  save)
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{

public static void Main()

{

var data = "Hello world";

Console.WriteLine(data.Replace(" ","").ToCharArray().Distinct().ToArray());

2.git fetch and pull difference


using System; using System.Collections.Generic; class Program { static void Main() { string data = "Hello world"; HashSet<char> seen = new HashSet<char>(); string result = ""; foreach (char c in data) { if (c != ' ' && !seen.Contains(c)) // Ignore spaces and duplicates { seen.Add(c); result += c; } } Console.WriteLine(result); // Output: Helowrd } }

Explanation

  1. Use a HashSet<char> to store unique characters.
  2. Loop through each character in the string.
  3. Skip spaces (c != ' ') and only add characters if they haven’t been seen before (!seen.Contains(c)).
  4. Build the result string without duplicates.

Why Use HashSet?

  • Faster lookup (O(1) time complexity for checking if a character is already seen).
  • Efficient way to remove duplicates compared to nested loops.


Difference Between git fetch and git pull

Both git fetch and git pull are used to get updates from a remote repository, but they work differently.

Featuregit fetchgit pull
OperationDownloads changes from the remote repository but does not merge themDownloads changes and automatically merges them into the current branch
MergingNo merging; updates only the remote-tracking branchesMerges remote changes into the current branch
Use CaseWhen you want to check for updates before mergingWhen you want to update your local branch immediately
RiskNo risk; does not change the working directoryPotential conflicts if changes clash with local work
Command Examplegit fetch origingit pull origin main

Tuesday, 4 March 2025

duplicate remove

 WITH CTE as(

select *,ROW_NUMBER () over (PARTITION BY User_ID order by Approver_Sequence) as row_num FROM tbl_WorkFlowMembers where 

WorkFlow_ID ='RAILCHLuz00001')

delete from cte

where row_num >1

delete duplicate record

over paritition must be use Order by....

Udemy courses

 https://github.com/prateek27/design-patterns-java


COurse Link

AFI workflow member sequence change

 USER_ID Approver_Sequence NewSequence

mlfoster 2 1

ismirnova4 2

hnandha 6 3

tpenny 7 4

cmignat 8 5

ytan      9      6

blerner 10 7

cheuschmid 11 8

tvadaketh 12 9

ngrasberger 13 10

using rownumber will update it 
cte first 

SELECT USER_ID, Approver_Sequence, 

           ROW_NUMBER() OVER (ORDER BY Approver_Sequence ) AS NewSequence

    FROM tbl_WorkFlowMembers

where WorkFlow_ID='RAILAUBre00001'

WITH OrderedApprovers AS (

SELECT USER_ID, Approver_Sequence, 

           ROW_NUMBER() OVER (ORDER BY Approver_Sequence ) AS NewSequence

    FROM tbl_WorkFlowMembers

where WorkFlow_ID='RAILAUBre00001'

)

UPDATE tbl_WorkFlowMembers

SET Approver_Sequence = OrderedApprovers.NewSequence

FROM tbl_WorkFlowMembers

JOIN OrderedApprovers ON tbl_WorkFlowMembers.User_ID = OrderedApprovers.User_ID

where  WorkFlow_ID='RAILAUBre00001'

Add workflow memeber to the exixsting flow

requirement that add new approver in first step 
solution:
1.Update squence with +1 
2.then insert new record
 

UPDATE tbl_WorkFlowMembers

SET Approver_Sequence = Approver_Sequence + 1

WHERE WorkFlow_ID IN ('WF2013RAILGBNot000041',

'WF2014RAILUSSou000043',


INSERT INTO tbl_WorkFlowMembers (WorkFlow_ID,Division_ID,Country_Code,User_ID,User_Email,User_Title,Site_Location,Operation_ID,  Approver_Sequence)

SELECT WorkFlow_ID, 'RAIL',Country_Code, 'mlfoster','mlfoster@harsco.com','Global FP&A Director',Site_Location,Operation_ID, 1

FROM tbl_WorkFlowMembers

WHERE WorkFlow_ID IN ('WF2013RAILGBNot000041',

'WF2014RAILUSSou000043',

'WF2020RAILAUBre000036',

'WF2020RAILBRBra000036',

'WF2020RAILCHLuz000036',

)

AND Approver_Sequence = 2;

junior devops engnr

  Position Overview: We are a growing start up seeking a Junior Azure DevOps Engineer with 2 to 3 years of experience to support our Azure...