Posts

Showing posts with the label SQL

KB:SQL DDL/DML

Image
DDL (Data Definition Language) provides the ability to define, create and modify database objects such as tables, views, indexes, and users. DML (Data Manipulation Language) allows for manipulating data in a database, such as inserting, updating, and deleting records. In SQL, DDL (Data Definition Language) and DML (Data Manipulation Language) are two categories of SQL commands used for different purposes: Data Definition Language (DDL) DDL commands are used to define and manage database schema, which includes creating, altering, and deleting database objects such as tables, indexes, and views. Common DDL commands include: CREATE : Used to create database objects like tables, indexes, views, etc. Example: CREATE TABLE Employees ( EmployeeID int PRIMARY KEY, FirstName varchar ( 255 ), LastName varchar ( 255 ), BirthDate date ); ALTER : Used to modify an existing database object. Example: ALTER TABLE Employees ADD COLUMN Salary decimal ( 10 , 2 ); DROP : Used to...

KB: SQL openquery vs linked server

Good read: Openquery vs Linked Server   The linked server query, SQL Server is going to make decisions for you on how it mashes all the data together and returns the result set. By default, when you run a distributed query using a linked server, the query is processed locally. This may or may not be efficient, depending on how much data must be sent from the remote server to the local server for processing . Sometimes it is more efficient to pass through the query so that it is run on the remote server. This way, if the query must process many rows, it can process them on the remote server, and only return to the local server the results of the query. The OPENQUERY function is used to specify that a distributed query be processed on the remote server instead of the local server. The alternative to using Linked Servers is to use the OPENQUERY statement, also known as a pass through query. When using an OPENQUERY statement, the WHERE clause gets executed at the remote server and the ...