Blog

MySQL Generated Column

Virtual and stored generated columns are both available in MySQL. Every time data is read, the virtual columns are calculated instantly, but when data is updated, the stored columns are calculated and physically saved. This is equivalent to a calculated column in SQL Server that is either virtual or physically stored. An expression that is part…

MySQL Generated column from another table

No, if this is what you are trying to achieve, then it isn’t supported in any SQL product. Sometimes we may require a generated/computed column in MySQL that references other tables. However, this isn’t supported and not a practical solution to have a reference of another column. The following code will return a syntax error.…

Third Highest Salary in SQL Server

For the majority of data retrievals, there are workarounds. In SQL, sub-queries can be used, although joins are also an option in the majority of situations. Most of the time, you can achieve a goal by using built-in functions rather than inner queries. The example that follows shows how to extract the third-highest salary from…

DATE FORMAT in SQL

SQL date formatting is a common task. When creating reports or getting data, everyone tries to convert the date. In SQL Server, the date can be formatted in a variety of ways. Method-1: SELECT Ename, FORMAT(HireDate, ‘d MMM yyyy hh:mm:ss.sss’) as JoinDate FROM Emp Output: 17 Dec 1980 12:00:00.00 Method-2: SELECT Ename, CONVERT(VARCHAR(40), HireDate, 113)…

Split alpha-numeric string into multiple columns in SQL Server

To break the string into numerous columns, a certain pattern should be used. Splitting a string can be done using various delimiters such as a comma, semicolon, or tab, or it can be split using the amount of characters provided as input. Here’s an example of combining a username and a phone number into a…

BULK INSERT in SQL Server

In SQL Server, bulk insert imports a data file in a user-specified format into a database table or view. We’ll be able to import CSV, TXT, DAT, and other files into SQL Server with this command. Before inserting data into a table, it must exist. Example for TEXT file: BULK INSERT tbVehicleDetails FROM ‘C:\Users\User\Documents\VehicleDetails.txt’ WITH…

SSRS Expressions on Field Values

Usually, the Stored Procedures that were called in the SSRS report contain practically all of the formatting and conversion already. However, you can still convert or format the data while creating the report in SSDT if you are unsure of the data and when you have control over the report rather than the source code.…

Report Generation Date in SSRS

In addition to the data, there are a few more elements that should be in the report. “Report Generation Date” is among them. This will inform others when the report that was shared is being prepared. Take a text box in the report’s data section and enter the following expression. =”Report Generated Date: ” &…

Multiple Tables Row Count in Single Query in SQL Server

The following SQL Server query can be used to view multiple tables’ row counts in one single SELECT statement. CREATE TABLE Dept( EmployeeDetails VARCHAR(100)); INSERT INTO Dept VALUES (‘John|Sales Team’), (‘Mike|Sales’), (‘Smith|Development’), (‘Jim|New Sales Team’), (‘Lucy|Development’), (‘Will|Development’); CREATE TABLE tbStudents(iStudentID INT, StudentName VARCHAR(10), SubjectName VARCHAR(30)); INSERT INTO tbStudents VALUES (1, ‘John’, ‘Mathematics’), (1, ‘John’, ‘Science’),…

Loading…

Something went wrong. Please refresh the page and/or try again.


Follow My Blog

Get new content delivered directly to your inbox.