Posts

Showing posts from April, 2021

SQL Server, speaking about ALIAS ...learn the rule

Image
Hello friends! Welcome back to this short post. We will speak about Alias and only two minute to learn some important things is really a big deal ! So think big and think that Share knowledge is the only way! Alias I think that everyone know what an alias is. We can have a table and call it with another name or we can have a field of a table and call it with another another name. SELECT CODE FROM ORDTES SELECT CODE as CODICE FROM ORDTES as ORDINI  Where 'as' is optional   Using alias if your statement represents a derived table then you can refer to it through the alias: SELECT * FROM ORTDES JOIN (SELECT CODE AS CODICE FROM ORDTES) AS ORDINI ON ORDINI.CODICE = ORDTES.CODE   Tips: You can see the Alias also int the execution plan   And then.. Suppose now to play with our usual ORDTES table. Suppose again you need to write a statement to get the max number of document. Using a not efficient way (i know) we could write: SELECT id FROM ORDTES d

Speaking to Sql Server, sniffing the TDS protocol

Image
Hello friends!  If yesterday you read my post and found it definitely boring (for the topic of course and not for how it was written to the author 😁) well today I promise you that the topic will be much more interesting! Let's talk about Sniffing , let's talk about going to see what happens when we "log in" or when we send a Query to SQL Server.  We will do this by taking a look to the little known tabular data stream (TDS) protocol built on top of the TCP/IP protocol. Ready! The TDS protocol What is the Tabular data stream (TDS) protocol?  The TDS is the protocol used by the SQL Server client Net-Library to communicates with SQL Server . TDS is specific to SQL Server and it is a low-level protocol that specifies both commands and data in a specific arrangement.  TDS encapsulate the TCP/IP protocol. Sniffing TDS packets you can read from the network the requests that your application do to the SQL Server and read the answer .   How to Sniff data from the network

Speaking to Sql Server, between Shared Memory, Named pipe and TCP/IP protocols

Image
Hi Friends, I hope you have had an Happy Easter! Have you ever wondered how your application or the SSMS itself talks to the database engine? Let's start today by talking about some basic concepts: Protocols GO!   Speaking to the database engine. You know already, from the previous posts, that SQL Server engine is a service . The database engine is a service   The question of today as sayd is: how do the applications speak to this service? How does he respond? Well, to talk to SQL Server there are three protocols that you can view by starting Sql Server Configuration Manager . These three protocols are named: Shared Memory Named Pipe TCP/IP Basically: With the Shared Memory protocol , the simplest protocol, you can only use it in a local connection . In this case the application and the SQL Server need to run on the same machine. The Named Pipe is used to connect inside a local area network (LAN)  With the TCP/IP protocol (the most used) you can have a remote or client/server c