Results for "mysql"
30 / 184 posts
What is the difference between DELETE and TRUNCATE statements in SQL?
--What is the difference between DELETE and TRUNCATE statements in SQL? --DELETE and TRUNCATE are both SQL commands that can be used to remove data from a …
How to comma separate value by using XML in SQL server
Before SQL Server 2017 (14.x), you can achieve the comma-separated values using the XML method. Here's an example of how you can achieve this: DECLARE @Sta…
Added columns in a table by dynamic ways
IF OBJECT_ID('AddedDynamicColumn','P') IS NOT NULL BEGIN DROP PROC AddedDynamicColumn END GO CREATE PROCEDURE AddedDynamicColumn AS BEGIN SELECT ED.empid,E…
How to get first date of given date or month.
Get First date of month: SELECT DATEFROMPARTS(YEAR(GETDATE()), MONTH(GETDATE()), 1) AS FirstDayOfCurrentMonth Create function for that IF NOT EXISTS (SELEC…
How to Two series with comma separate(any Delimiter) value split into in rows respectively
If we have two series with comma separate(any Delimiter) value and we want split into in rows, I have create function for that: IF OBJECT_ID('TF_SplitTwoSe…
Use of Apply(Cross and Outer) operator in SQL server
APPLY operator joins two table expressions. Also, I'll show how it differs from regular JOINs. Operator: CROSS APPLY Similar: INNER JOIN When to Use: Use a…
Find column in the whole database in sql server
To find a specific column in the whole database in SQL Server, you can query the information schema views. Here's a query you can use: SELECT table_name, c…
How to use Magic (virtual) table INSERTED and DELETED in SQL server
Magic Tables are virtual tables that are automatically created and maintained by SQL Server for each data modification operation performed on a table. They…
UNION, UNION All, INTERSECT, EXCEPT used in SQL Server
UNION : The UNION operator is used to combine the result sets of two or more SELECT statements into a single result set. It removes duplicate rows from the…
What is an Index? Explain its different types in SQL
✅ Index in SQL Server (इंडेक्स इन SQL सर्वर): Index SQL Server में एक database object (डेटाबेस ऑब्जेक्ट) है जो टेबल के डेटा को जल्दी से प्राप्त करने के लिए…
What is View in SQL server
A view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table. IF OBJECT_ID('ViewTable','…
Normalization in Databases
Normalization in a database is the process of organizing the data to reduce redundancy and improve data integrity. The main goal of normalization is to bre…
Triggers in SQL server
A trigger in SQL is a special type of stored procedure that runs automatically when certain actions happen in a table or view . A trigger cannot be explici…
Window Aggregate Functions in SQL
What is window function: Imagine you have a dataset with many rows, and you want to perform some calculations on each row based on a group of rows related …
Implementing Transactions,Error Handling, and Dynamic SQL in SQL
Think of a transaction as a complete package deal. It's like when you buy something from a store. You give them money, and in return, you expect to get the…
What are Constraints in SQL?
SQL में constraints डेटाबेस टेबल में डेटा को सुरक्षित और सही बनाए रखने के लिए उपयोग किए जाते हैं। ये टेबल में डेटा की वैधता (validity) और अखंडता (integrity…
ANY and ALL operators used in SQL
The ANY operator: returns a boolean value as a result returns TRUE if any of the sub-query values meet the condition Any means that the condition will be t…
Order by index number in SQL
SELECT empid, lastname FROM HR.Employees ORDER BY 1 DESC --order by first column SELECT empid, lastname FROM HR.Employees ORDER BY 2 DESC --order by second…
Logical Query Processing Phases in SQL
SQL query processing consists of several logical phases, which describe the order in which SQL statements are evaluated. These phases help in understanding…
Filtering the data with TOP and OFFSET-FETCH In SQL
TOP: SELECT TOP (5) productid, unitprice FROM Production.Products WHERE categoryid = 1 ORDER BY unitprice DESC; SELECT TOP (5) WITH TIES productid, unitpri…
How to get first date From month and Finyear
If we have Finyear and month then we create a date for examples: DECLARE @finyear CHAR(5) = '202425'; DECLARE @month smallint = 5; --Get Year DECLARE @year…
Insert <br> tag in SQL text string
CREATE or ALTER FUNCTION dbo.Fn_InserBRtag(@inputString NVARCHAR(MAX)) RETURNS NVARCHAR(MAX) AS BEGIN DECLARE @resultString NVARCHAR(MAX) = ''; DECLARE @st…
What is Power BI
Power BI is a suite of business analytics tools developed by Microsoft that allows you to visualize and share insights from your data. Power BI consists of…
Schema and Handling Corrupt data in PySpark
A schema in PySpark (and generally in data processing) defines the structure of a DataFrame, including the names and data types of each column. It serves a…
Pivoting and Unpivoting Data in SQL
Pivoting Data : Pivoting is the process of converting rows of data into columns, effectively changing the orientation of your data. It's useful when you ha…
Store Error Logs In SQL
Create Table for Error log: CREATE TABLE [dbo].[ErrorLog]( [ErrorLogID] [int] IDENTITY(1,1) NOT NULL, [ErrorTime] [datetime] …
What difference between between MySQL and MSSQL
Feature MySQL MSSQL Ownership Oracle Corporation Microsoft Licensing Open-source (GPL) and commercial versions Commercial with free Express Edition Operati…
Variables In MySQL
Variables are used to store values temporarily during the execution of SQL queries. There are two main types of variables in MySQL: Session Variables : Ses…
Stored Procedure in MySQL
Syntax for Creating a Stored Procedure DELIMITER // CREATE PROCEDURE procedure_name (IN param1 data_type, OUT param2 data_type) BEGIN -- SQL statements END…
Functions in MySQL
In MySQL, a Function is similar to a Stored Procedure but with some key differences. Functions are used to perform calculations or operations and return a …