Skip to main content

Posts

How to Create, Update, Insert and Delete SQL Views? Is it posible to do?

Yes, it is possible to Create , Update , Insert , and Delete data in SQL Views under certain conditions. SQL views allow you to define a virtual table based on the result of an SQL query. They are useful for simplifying complex queries, providing abstraction, and improving security. 1. Creating a View You can create a view using the CREATE VIEW statement. This defines a virtual table based on a SQL query. Syntax: CREATE VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition ; Example: CREATE VIEW EmployeeView AS SELECT EmployeeID, FirstName, LastName, Department FROM Employees WHERE Department = 'HR' ; 2. Updating a View To modify an existing view, you can use the ALTER VIEW statement. It allows you to change the definition of the view. Syntax: ALTER VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition ; Example: ALTER VIEW EmployeeView AS SELECT EmployeeID, FirstName, LastName, Department, Salary FROM
Recent posts

constructors vs ngOnInit in Angular and .net c# Init

 In Angular, constructors and ngOnInit are both important lifecycle methods, but they serve different purposes and are called at different times. Here's how they work and the order in which they are called: 1. Constructor : The constructor is a method that is invoked first when a component is instantiated. It is used primarily for dependency injection (DI) and initial setup , but it shouldn't contain complex logic or interact with DOM elements since the component isn't fully initialized at this stage. 2. ngOnInit : The ngOnInit() method is part of Angular's component lifecycle hooks and is called after the constructor . It is executed once the component’s input properties are initialized, and is a good place to put logic that depends on the component being fully initialized, like making HTTP requests or setting up component properties based on input values. Order of Execution in Angular: Constructor : Called when the component is created. This is where dependency

forkJoin in Angular 17 | RxJS library

 It seems like you are asking about forkJoin in Angular. forkJoin is a method from the RxJS library that allows you to execute multiple observable requests in parallel and wait for all of them to complete before taking action. What is forkJoin ? forkJoin is commonly used when you need to execute multiple HTTP requests (or other observables) in parallel and only proceed once all the observables have completed. It combines the values emitted by each of the observables into a single array (or object) of results, which you can then process. Key Points About forkJoin : It waits for all observables to complete. It emits the last value of each observable. If one of the observables fails , the entire forkJoin will fail (i.e., it will not emit any value). Usage of forkJoin in Angular To use forkJoin in an Angular application, you typically import it from RxJS and use it within a service or component to manage multiple HTTP requests or other asynchronous operations. Example Scenario:

Dependency Injection vs Factory Pattern

The Factory Design Pattern and Dependency Injection (DI) are both design patterns used to manage object creation and dependencies in software development, but they serve different purposes and are used in different contexts. Here's a detailed comparison: Factory Design Pattern : Purpose : Handles object creation. Focus : Centers on how objects are created. Responsibility : The factory class is responsible for creating objects. Coupling : Can result in tighter coupling between the client and the factory. Control : The factory controls which objects are created. When to Use : When object creation is complex or requires abstraction. Testability : Less test-friendly, as it can tightly couple creation logic to the client. Dependency Injection (DI) : Purpose : Provides dependencies to a class. Focus : Centers on how dependencies are provided. Responsibility : The DI container or framework is responsible for injecting dependencies. Coupling : Encourages loose coupling by decoupling ob

Add Godaddy SSL Certificate to IIS 10 Server | Rekey

How to Add Godaddy SSL Certificate to IIS 10 (Full 2024 Guide)? Installing Godaddy SSL Certificate on IIS 10 Server? Rekey and Install SSL Certificate in IIS 10 Server? Manually Install an SSL Certificate on my IIS 10 Server? Download the SSL Certificate from GoDaddy: ·         Go to your GoDaddy account and navigate to the SSL Certificates section. ·         Find your issued SSL certificate and click Download. ·         Choose the correct server type from the dropdown and download the certificate files (usually a .crt file). Create the .pfx file using the below OpenSSL command prompt: openssl pkcs12 -export -out certificate.pfx -inkey generated-private-key.txt -in 530276e452e0d3fb.crt -certfile 530276e452e0d3fb.crt As per above command: ·         Downloaded the 'Generated Private Key' text file: generated-private-key.txt ·         Download CRT file:   530276e452e0d3fb.crt ·         New PFX file that will create in the folder with certificate name (as per y

Odd Even Numbers 1 to 10 program in c#

 Question on the Odd-Even Numbers 1 to 10 program in c# 1. Print all even numbers from 1 to 10  2. Print the sum of all odd numbers from 1 to 10 3. Print all numbers from 1 to 10 that are divisible by 3 Explanation: Even Numbers:  The program uses a  for  loop to iterate through numbers from 1 to 10. It checks if a number is even using  i % 2 == 0  and prints it if true. Sum of Odd Numbers:  The program calculates the sum of odd numbers by checking if a number is odd using  i % 2 != 0  and adding it to the  sumOfOdds   variable. Numbers Divisible by 3:  The program checks each number from 1 to 10 to see if it's divisible by 3 using  i % 3 == 0  and prints it if true. Example, class EvenOddNumber {     static void Main()     {         // 1. Print all even numbers from 1 to 10         Console.WriteLine("Even numbers from 1 to 10:");         for (int i = 1; i <= 10; i++)         {             if (i % 2 == 0)             {                 Console.WriteLine(i);            

Promises in JavaScript | Promises in JavaScript are a powerful way to handle asynchronous operations.

Promises in JavaScript are a powerful way to handle asynchronous operations. They represent a value that may be available now, or in the future, or never. Promises provide a cleaner and more intuitive way to work with asynchronous code compared to traditional callback-based approaches. Basics of Promises A Promise object represents an asynchronous operation's eventual completion (or failure) and its resulting value.  Promises can be in one of three states: Pending : The initial state. Neither fulfilled nor rejected. Fulfilled : The operation completed successfully. Rejected : The operation failed. Creating a Promise: You create a new Promise using the Promise constructor, which takes a function (called the executor function) that has two parameters: resolve and reject . //Promises in JavaScript - Promises in JavaScript are a powerful way to handle asynchronous operations. //Promises can be in one of three states: //Pending: The initial state. Neither fulfilled nor rejected. //

To count the number of vowel characters in a string using JavaScript

//To count the number of vowel characters in a string using JavaScript let message = 'Hello w0rld' ; let vowels = 'aeiou' let count = 0 //solution 1 for ( let chr of message ){     if ( vowels . includes ( chr )){     count = count + 1 ;    }   } console . log ( "Solution1: " + count ); //solution 2 function countVowels ( data ){   let count = 0 ;   data . split ( '' ). forEach ( x => {     if ( vowels . includes ( x )){         count = count + 1 ;     }   });   return count ; } let countVowel = countVowels ( message ); console . log ( "Solution2: " + countVowel );

Count a vowels from a given string in sql server

 To count the number of vowels in a given string in SQL Server , you can use a combination of CHARINDEX and WHILE loop Example, /* Count a vowels from a given string in sql server */ DECLARE @stringHello VARCHAR(1000) ='Hello world example' DECLARE @vowel TABLE(  id INT IDENTITY(1,1) ,  vowels VARCHAR(1) ) INSERT INTO @vowel SELECT 'a' INSERT INTO @vowel SELECT 'e' INSERT INTO @vowel SELECT 'i' INSERT INTO @vowel SELECT 'o' INSERT INTO @vowel SELECT 'u' DECLARE @i INT=1 DECLARE @count INT = (SELECT COUNT(1) FROM @vowel) DECLARE @vowelCount INT=0 WHILE(@i <=@count) BEGIN    IF( SELECT CHARINDEX( (SELECT vowels FROM @vowel WHERE id= @i)  ,@stringHello )  )>0 BEGIN SET @vowelCount = @vowelCount +1 END SET @i =@i+1 END SELECT @vowelCount AS VowelsCharCount

create a custom prototype in JavaScript

  * JavaScript implements inheritance by using objects. Each object has an internal link to another object called its prototype. * Prototypes are hidden objects that are used to share the properties and methods of a parent class to child classes. Live result:-  https://playcode.io/1943770 /* Find the age greater than 10 from an array of age */ var age = [ 10 , 11 , 2 , 1 , 20 ]; /*Solution 1 with .filter() function*/ let result = age . filter ( function ( a ){   return a > 10 }); console . log ( 'Age greater than 10 : ' , result ); /*Solution 2 using custom prototype method ' showAgeGreaterThan10' */ Array . prototype . showAgeGreaterThan10 = function () {   return (       age . filter ( function ( val ){       return val > 10     })  ) }; console . log ( 'Custom prototype :' , age . showAgeGreaterThan10 ());