[{"content":"Picture typing a single command on Linux, an insmod, and watching the macOS login screen show up. No virtual machine in between. Apple\u0026rsquo;s kernel loaded like any other driver, sharing the same CPU with Linux. That\u0026rsquo;s what a project published on GitHub on November 20, 2026 is showing. And it made it all the way to Finder, the Dock and Safari.\nImage: xnulinux project (Heyang Zhou and contributors) — source\nFirst, what is this XNU thing Every operating system has a kernel, the part that talks straight to the hardware: memory, processor, disk, network. On Linux, the kernel is Linux itself. On macOS, it\u0026rsquo;s called XNU, short for \u0026ldquo;X is Not Unix\u0026rdquo;.\nXNU was born at NeXT, for the NeXTSTEP system, and Apple has been developing it since December 1996. It\u0026rsquo;s a hybrid kernel. It combines Mach, a microkernel created at Carnegie Mellon University, with a good chunk of BSD code. The detail that matters today is that Apple publishes XNU\u0026rsquo;s source code as open source, under the APSL license. In other words, anyone can download it and compile it.\nBut compiling the kernel is one thing. Getting it to run, bring up the whole macOS graphical interface and open apps is a very different thing.\nWhat the xnulinux project pulled off The repository is called xnulinux and lives under the AFK-surf account. The footer credits Heyang Zhou and contributors. According to the GitHub API, it was created on November 20, 2026. Three days later, it already had almost 2,000 stars and nearly 600 points on Hacker News.\nThe pitch, in the README\u0026rsquo;s words, is to run macOS userspace on Linux by loading the macOS kernel into it. XNU is built from the code Apple publishes and becomes a loadable module, xnu.ko. That module goes into an arm64 Linux kernel with no modifications at all. The author says that with the stock Ubuntu kernel, insmod xnu.ko boots a macOS 27 system disk to the desktop, with loginwindow, WindowServer, Dock, Finder, Safari and Chrome.\nHe tested two setups. The first is an Apple Silicon Mac running an arm64 Linux virtual machine. There, according to the project, macOS 27.2.1 reaches the desktop in 31 to 48 seconds. A regular macOS VM on the same Mac took 49. The author also reports a 30-minute stress test, with 40 rounds of opening Safari, Notes, Calculator and System Settings, without a single kernel panic.\nThe second setup is the eye-catching one: an NVIDIA DGX Spark, with no virtualization at all, running Ubuntu directly on the machine. macOS boots with 4 cores and 8 GB of RAM reserved for XNU. There, for now, the screen is drawn by the CPU, because the GPU bridge only works with a virtual GPU.\nImage: xnulinux project (Heyang Zhou and contributors) — source\nAn honest caveat: all of these numbers come from the repository itself. Phoronix also covered the project, but so far I haven\u0026rsquo;t seen anyone independent reproducing the tests.\nHow two kernels share the same machine This is the part I find most interesting. Normally, to run one system inside another, you use a hypervisor, the software that creates virtual machines. xnulinux doesn\u0026rsquo;t. XNU drives the CPU and the MMU, the unit that translates memory addresses, directly.\nThe trick lives in a second module, fki.ko. The name stands for \u0026ldquo;foreign kernel interface\u0026rdquo;. It\u0026rsquo;s what lends XNU the things that belong to Linux: memory, timers, files, network and GPU.\nIn practice, it works like this. Each CPU macOS sees is actually a Linux kernel thread pinned to a physical core. XNU runs on that thread until it needs something from the host, like waiting on a timer or doing I/O. Then it hands control back. When a page fault or an exception happens in XNU code, fki.ko forwards it to XNU\u0026rsquo;s own handler.\nMemory is one contiguous block that Linux sets aside right at the start, and XNU manages that block its own way. The macOS disk is a file on the Linux side. The network is a Linux network interface. Even Metal, Apple\u0026rsquo;s graphics API, gets translated to Vulkan and reaches the host GPU through a bridge.\nImage: Robryecran77 / Wikimedia Commons, CC BY-SA 4.0 — source\nThen there are the licenses, which are both a technical and a legal piece. fki.ko is GPL 2.0, the Linux license. xnu.ko and the XNU patches stay under the APSL, Apple\u0026rsquo;s license. That split is on purpose. The idea of wrapping XNU in a Linux module isn\u0026rsquo;t even new: Darling, a compatibility layer that runs macOS programs on Linux, already does something similar, but there the module mostly handles communication between processes. xnulinux goes much further and boots the whole system.\nWhy this matters even if you\u0026rsquo;ll never run macOS on Linux To start with, the project doesn\u0026rsquo;t ship anything from Apple. According to the README, you need your own macOS 27 installation, made with the official installer, and a Mac with Xcode to build the disk. You also need an arm64 Linux machine with at least 16 GB of RAM. So this isn\u0026rsquo;t something for your x86 PC today.\nWhat matters for developers and infrastructure folks is what it shows. A kernel doesn\u0026rsquo;t have to be the absolute owner of the machine. With a well-designed interface, you can put two kernels from different families side by side, each with its own processes. Today this looks like a lab experiment. But I\u0026rsquo;d bet ideas like this resurface down the road in lightweight virtualization and in testing tools.\nImage: xnulinux project (Heyang Zhou and contributors) — source\nMy take It\u0026rsquo;s impressive, but it\u0026rsquo;s a proof of concept, and the author makes that clear. In the docs, he lists what is still a stopgap. The macOS system partition loses its integrity seal. AMFI, the mechanism that checks code signatures, gets patched. SIP, System Integrity Protection, is relaxed. Kernel address randomization is turned off. And code that leans heavily on memory can be up to 1.6 times slower.\nMy reading is that today it\u0026rsquo;s for learning, not for production. There\u0026rsquo;s also a question the README doesn\u0026rsquo;t answer: whether running macOS this way, especially on hardware that isn\u0026rsquo;t Apple\u0026rsquo;s, like the DGX Spark, complies with the macOS license. I\u0026rsquo;m not a lawyer. But before using this at a company, I\u0026rsquo;d ask that question.\nWhat now? If you have an Apple Silicon Mac and like tinkering with operating systems, the README is the place to go. It has the build scripts step by step and a page just for the current limitations. If you don\u0026rsquo;t, it\u0026rsquo;s still worth reading the section that explains how the project works. You rarely get to see, in a short text, how two kernels manage to live together.\nA kernel Apple built for Macs booting as a module inside Linux, three days into a public project. What would you use this for? Tell me in the comments.\nSources xnulinux — official GitHub repository (README) xnulinux — docs/production.md (current limitations) XNU source code published by Apple XNU — Wikipedia Darling (software) — Wikipedia Phoronix — XNU Linux Lets macOS Userspace Processes Run On Linux ","date":"2026-11-23T20:30:00-03:00","image":"https://alencarinosql.com.br/p/xnu-linux-macos-como-modulo-do-kernel-linux/capa_hu_1db58e98cfe0aa69.jpg","permalink":"https://alencarinosql.com.br/en/p/xnu-linux-macos-como-modulo-do-kernel-linux/","title":"XNU Linux: the macOS kernel running as a module inside Linux"},{"content":"Hi everyone! As an old friend of SQL Server, I know we often need to integrate data that lives on different servers. That\u0026rsquo;s where the Linked Server comes in, acting as a solid bridge between separate data environments. In this post, we\u0026rsquo;ll go deep into Linked Servers, from basic setup to advanced tips and troubleshooting. Get ready to see everything this tool can do!\nWhat Is a Linked Server and Why Do You Need One? Imagine you have sales data on one server and customer information on another. Or maybe your main system runs on an older SQL Server, but you need to pull data from a financial system running on a newer instance, or even on Oracle, DB2 or MySQL. A Linked Server is exactly what you need!\nIn simple terms, a Linked Server is a SQL Server setting that lets one SQL Server instance run commands against another OLE DB data source. That data source can be another SQL Server instance (local or remote), Oracle, MySQL, DB2, and even an Excel or CSV file (yes, you read that right!). It works as a \u0026ldquo;shortcut\u0026rdquo; to external data, making it possible to run queries, updates and even create objects on remote servers, all from your local instance.\nBut why use a Linked Server? There are plenty of reasons:\nData Integration: Bring together data from different sources for reports, analysis or migrations. Distributed Queries: Run queries that span multiple servers without having to move the data. ETL Processes (Extract, Transform, Load): Make it easier to extract and load data between systems. Centralized Management: Access data from different environments through a single interface. Less Network Traffic: In some scenarios, it can be more efficient to query the data on the source server than to transfer large volumes. Hands-On: Configuring a Linked Server Setting up a Linked Server can look intimidating at first, but I promise it\u0026rsquo;s simpler than it seems. Let\u0026rsquo;s go step by step, both in SQL Server Management Studio (SSMS) and with T-SQL.\nUsing SQL Server Management Studio (SSMS) This is the most visual and intuitive way if you\u0026rsquo;re just getting started:\nConnect with SSMS: Open SQL Server Management Studio and connect to the instance where you want to create the Linked Server. Go to \u0026ldquo;Server Objects\u0026rdquo;: In Object Explorer, expand \u0026ldquo;Server Objects\u0026rdquo;. Expand \u0026ldquo;Linked Servers\u0026rdquo;: Inside \u0026ldquo;Server Objects\u0026rdquo;, expand \u0026ldquo;Linked Servers\u0026rdquo;. New Linked Server: Right-click \u0026ldquo;Linked Servers\u0026rdquo; and select \u0026ldquo;New Linked Server…\u0026rdquo;. Fill in the Information: A new \u0026ldquo;New Linked Server\u0026rdquo; window opens. This is where the magic happens. General Page: Linked server: Give your Linked Server a meaningful name. This is the name you\u0026rsquo;ll use in your queries (e.g. MEU_SERVER_REMOTO). Server type: SQL Server: If you\u0026rsquo;re connecting to another SQL Server instance, select this option. Other data source: For other data sources (Oracle, MySQL, Excel, etc.), select this one and choose the appropriate OLE DB provider. For SQL Server, this option is more generic and lets you specify the provider and connection string manually. Product name: For SQL Server, we usually fill in \u0026ldquo;SQL Server\u0026rdquo;. For others, the product name (e.g. \u0026ldquo;Oracle\u0026rdquo;). Data source: The name or IP address of the remote server. If it\u0026rsquo;s a named instance (e.g. SEUSQL\\INSTANCIA), use SEUSQL\\INSTANCIA. Provider string: Leave it blank for standard SQL Server. Other providers may need extra connection parameters. Catalog: The default database name on the remote server for this Linked Server. Optional, but useful. Security Page: This one is crucial for authentication. Not be made: No security context. Not recommended for most scenarios. Be made using the login\u0026rsquo;s current security context: Authentication uses the credentials of the user running the query on the local server. Useful in domain environments with integrated Windows authentication. Be made using a security context that the login\u0026rsquo;s current security context does not support: For users that aren\u0026rsquo;t mapped. Be made using this security context: This is the most common and flexible option. You specify a remote login (user and password) that will be used to access the linked server. Remote login: The user name on the remote server. With password: The password for the remote user. Add: Map specific local server logins to specific remote server logins. Very useful for fine-grained security. Server Options Page: Collation Compatible: If the servers have different collation settings and you need the Linked Server to handle that. Data Access: Enables or disables data access. RPC, RPC Out: Allow remote procedure calls. Essential for running remote stored procedures. Use Remote Collation: Uses the remote server\u0026rsquo;s collation. Click OK: Your Linked Server is ready! Using T-SQL (Transact-SQL) If you prefer automation and full control, T-SQL is the way to go. The basic syntax is:\n1 2 3 4 5 6 7 8 9 10 11 12 EXEC sp_addlinkedserver @server = \u0026#39;MEU_SERVER_REMOTO\u0026#39;, -- Linked Server name @srvproduct = \u0026#39;SQL Server\u0026#39;, -- Remote server product (e.g. \u0026#39;SQL Server\u0026#39;, \u0026#39;Oracle\u0026#39;) @provider = \u0026#39;SQLNCLI11\u0026#39;, -- OLE DB provider (SQLNCLI11 for SQL Server 2012 and later, SQLOLEDB for older versions) @datasrc = \u0026#39;NOME_OU_IP_DO_SERVER_REMOTO\\INSTANCIA_REMOTO\u0026#39;; -- Data source (server name or IP, with instance if applicable) EXEC sp_addlinkedsrvlogin @rmtsrvname = \u0026#39;MEU_SERVER_REMOTO\u0026#39;, -- Linked Server name @useself = \u0026#39;FALSE\u0026#39;, -- \u0026#39;TRUE\u0026#39; to use the current security context, \u0026#39;FALSE\u0026#39; to specify a login @locallogin = NULL, -- Local login (NULL for all local logins) @rmtuser = \u0026#39;usuario_remoto\u0026#39;, -- Remote login @rmtpassword = \u0026#39;sua_senha_secreta\u0026#39;; -- Remote login password Important notes:\n@provider: For SQL Server, SQLNCLI11 is the recommended provider for SQL Server 2012 and later. For older versions (up to SQL Server 2008 R2), SQLOLEDB was the default. Make sure the provider is installed and registered. @locallogin: If you want only one specific login on your local server to be able to use this Linked Server, replace NULL with the local login name. Otherwise, NULL lets any local login use the mapping. sp_addlinkedsrvlogin: You can call sp_addlinkedsrvlogin multiple times to map different local logins to different remote logins, or to map local logins to the current security context (@useself = 'TRUE'). Testing and Using Your Linked Server Once it\u0026rsquo;s configured, it\u0026rsquo;s time to test!\nQuerying Data The most common way to use a Linked Server is through four-part name queries:\n1 2 3 4 5 6 7 SELECT * FROM MEU_SERVER_REMOTO.NomeDoBancoDeDados.NomeDoSchema.NomeDaTabela; -- Real example: SELECT c.NomeCliente, p.NomeProduto FROM MEU_SERVER_REMOTO.VendasDB.dbo.Clientes c INNER JOIN SEGUNDO_SERVER.EstoqueDB.dbo.Produtos p ON c.ProdutoID = p.ProdutoID; You can also use the OPENQUERY function for more complex queries or to improve performance, because it sends the query straight to the remote server to be executed there, not on the local server.\n1 2 SELECT * FROM OPENQUERY(MEU_SERVER_REMOTO, \u0026#39;SELECT ClienteID, NomeCliente FROM VendasDB.dbo.Clientes WHERE DataRegistro \u0026gt; GETDATE() - 30\u0026#39;); The OPENDATASOURCE function is similar, but it lets you specify the data source ad hoc, without a preconfigured Linked Server. Use it with care, because it\u0026rsquo;s less secure and more verbose.\n1 2 3 SELECT * FROM OPENDATASOURCE(\u0026#39;SQLNCLI11\u0026#39;, \u0026#39;Data Source=NOME_OU_IP_DO_SERVER_REMOTO\\INSTANCIA_REMOTO;Initial Catalog=VendasDB;User ID=usuario_remoto;Password=sua_senha_secreta\u0026#39;) .VendasDB.dbo.Clientes; Running Remote Stored Procedures Yes, you can! This is really useful for orchestrating processes across different servers.\n1 EXEC MEU_SERVER_REMOTO.NomeDoBancoDeDados.dbo.MinhaStoredProcedureRemota @Parametro1 = \u0026#39;Valor\u0026#39;; Managing and Troubleshooting Common Problems Even SQL Server experts run into challenges with Linked Servers. Here are some important points and troubleshooting tips:\nSecurity Security comes first.\nPrinciple of Least Privilege: Grant only the permissions the remote login needs. Don\u0026rsquo;t use sa or accounts with excessive privileges. Windows vs. SQL Server Authentication: Windows authentication is more secure, especially in domain environments. If you use SQL Server authentication, make sure passwords are strong and rotated regularly. Login Mapping: Use sp_addlinkedsrvlogin to map local logins to specific remote logins, for finer-grained security. Performance Linked Server queries can be slower because of network latency and the query optimizer.\nOPENQUERY: Use OPENQUERY whenever possible. It \u0026ldquo;pushes\u0026rdquo; the query to the remote server, minimizing network traffic and taking advantage of the source server\u0026rsquo;s query optimizer. Indexes: Make sure the tables you\u0026rsquo;re querying on the remote server have appropriate indexes. Simple Queries: Avoid complex queries or massive JOINs across servers if you can. Pull only the data you need. Data Transfer: For large data volumes, consider replication, SSIS or other ETL tools instead of direct Linked Server queries. Common Troubleshooting \u0026ldquo;Login failed for user…\u0026rdquo;: The most common error. Check the user name and password configured in sp_addlinkedsrvlogin (or on the Security tab in SSMS). Make sure the remote user has permission to access the required database and tables. \u0026ldquo;OLE DB provider \u0026lsquo;SQLNCLI11\u0026rsquo; for linked server \u0026lsquo;…\u0026rsquo; returned message \u0026lsquo;No process is on the other end of the pipe.\u0026rsquo;\u0026rdquo;: Usually points to a network connectivity problem (a firewall blocking port 1433), the SQL Server service on the remote server being stopped, or an incorrect server/instance name. \u0026ldquo;The OLE DB provider \u0026lsquo;SQLNCLI11\u0026rsquo; for linked server \u0026lsquo;…\u0026rsquo; reported an error. Access denied.\u0026rdquo;: The remote user has access to the server, but not permission for the specific action (SELECT, INSERT, UPDATE, DELETE) on the table/view you\u0026rsquo;re trying to access. \u0026ldquo;Cannot initialize the data source object of OLE DB provider \u0026lsquo;…\u0026rsquo; for linked server \u0026lsquo;…\u0026rsquo;\u0026rdquo;: A problem with the OLE DB provider. It may not be installed or registered correctly, or the connection string is wrong. Timeout Errors: Queries that take too long to respond can be cut off by timeouts. Adjust the Linked Server timeout settings in the server options (Server Options -\u0026gt; Connection Timeout, Query Timeout) or with sp_serveroption. Dropping a Linked Server If you need to remove a Linked Server:\n1 EXEC sp_dropserver \u0026#39;MEU_SERVER_REMOTO\u0026#39;, \u0026#39;droplogins\u0026#39;; The 'droplogins' argument makes sure the associated login mappings are removed too.\nFinal Thoughts and Next Steps The Linked Server is a powerful and versatile tool in any DBA\u0026rsquo;s or SQL Server developer\u0026rsquo;s toolkit. With it, you can build solid data integration solutions, consolidate information and streamline business processes.\nThat said, like any powerful tool, a Linked Server calls for understanding and good judgment. Don\u0026rsquo;t use it for everything! Always weigh your project\u0026rsquo;s needs:\nFor quick ad hoc queries across servers: A Linked Server is perfect. For large-scale data integration or complex ETL processes: Consider tools like SQL Server Integration Services (SSIS), Azure Data Factory, or other data orchestration solutions. For keeping synchronized copies of data: SQL Server Replication or Always On Availability Groups may be a better fit. I hope this detailed guide has demystified Linked Servers for you. It\u0026rsquo;s an excellent way to connect data worlds and expand what your SQL Server environment can do.\nIf you have any questions or suggestions, or want to share your experience with Linked Servers, leave a comment below! I\u0026rsquo;d love to hear how you\u0026rsquo;re using this tool in your projects.\nSee you next time, and happy coding!\n","date":"2025-07-27T12:00:00-03:00","permalink":"https://alencarinosql.com.br/en/p/linked-server/","title":"Linked Server"},{"content":"SQL Server Functions: Power and Best Practices Hi everyone! Today we\u0026rsquo;re digging into functions in SQL Server. They\u0026rsquo;re great tools for wrapping up logic and reusing code, but, like everything in SQL, they need some care so they don\u0026rsquo;t turn into a performance bottleneck.\nWhat Are Functions in SQL Server? A function in SQL Server is a database object that takes input parameters, runs a set of actions (queries, calculations, and so on) and returns either a single value (scalar) or a table. They\u0026rsquo;re similar to stored procedures, with one crucial difference: functions can be used inside SELECT statements, WHERE, HAVING, and even inside other functions, which makes them extremely versatile.\nThere are two main kinds of functions we can create:\nScalar Functions (Scalar-valued Functions - T-SQL): Return a single value of any data type. Table-valued Functions (TVFs): Return a table. They come in two flavors: Inline Table-valued Functions (iTVFs): Simpler and faster, because they essentially expand the function\u0026rsquo;s logic straight into the calling query, like a parameterized view. Multi-statement Table-valued Functions (mTVFs): Allow more complex logic, including multiple T-SQL statements, but can hurt performance significantly because of less aggressive optimizations and, often, the need to materialize data. Why Use Functions? Code Reuse: Write the logic once and use it in many places. Modularity: Break complex problems into smaller, more manageable pieces. Consistency: Make sure a specific business rule is applied the same way across the whole database. Simpler Maintenance: Changes to the logic only need to be made in one place. Creating Functions: Examples and Best Practices Let\u0026rsquo;s look at some examples and, more importantly, the best practices!\n1. Simple Scalar Function Imagine you need to calculate the total tax on a price.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 CREATE FUNCTION dbo.CalcularImposto (@Preco DECIMAL(18, 2), @PercentualImposto DECIMAL(5, 2)) RETURNS DECIMAL(18, 2) AS BEGIN RETURN @Preco * (@PercentualImposto / 100); END; GO -- Usage example SELECT Produto, PrecoUnitario, dbo.CalcularImposto(PrecoUnitario, 10.00) AS ValorImposto, PrecoUnitario + dbo.CalcularImposto(PrecoUnitario, 10.00) AS PrecoTotal FROM MinhaTabelaDeProdutos; Performance Tip: Scalar functions, especially ones that do complex work or access data, can cause performance problems when called for every row of large result sets (the dreaded RBAR - Row By Agonizing Row). Ask yourself whether the logic could be handled directly in your main query, or whether an iTVF would be a better fit.\n2. Table-valued Function (Inline TVF) If you need to return a result set based on parameters, iTVFs are your best friends for performance. The query optimizer handles them very efficiently.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 CREATE FUNCTION dbo.ObterProdutosPorCategoria (@Categoria NVARCHAR(50)) RETURNS TABLE AS RETURN ( SELECT ProdutoID, NomeProduto, Preco FROM Produtos WHERE Categoria = @Categoria ); GO -- Usage example SELECT p.ProdutoID, p.NomeProduto, p.Preco FROM dbo.ObterProdutosPorCategoria(\u0026#39;Eletrônicos\u0026#39;) AS p WHERE p.Preco \u0026gt; 500; Why is an iTVF better than an mTVF in most cases? The query optimizer can \u0026ldquo;inline\u0026rdquo; (expand) the iTVF logic directly into the calling query, which allows broader optimizations and effective use of indexes. mTVFs, on the other hand, often materialize their results in a worktable, which can block good optimizations.\n3. Table-valued Function (Multi-statement TVF) - Be Careful! Although they\u0026rsquo;re useful for complex logic involving multiple steps or variables, mTVFs should be used with caution because of their potential impact on performance.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 -- CAREFUL: This is an mTVF example; usually avoid it if an iTVF is possible. CREATE FUNCTION dbo.ObterRelatorioVendasMensal (@Ano INT, @Mes INT) RETURNS @Relatorio TABLE ( ProdutoID INT, NomeProduto NVARCHAR(255), TotalVendas DECIMAL(18, 2), MediaVendasDiaria DECIMAL(18, 2) ) AS BEGIN INSERT INTO @Relatorio (ProdutoID, NomeProduto, TotalVendas) SELECT p.ProdutoID, p.NomeProduto, SUM(iv.Quantidade * iv.PrecoUnitario) FROM Produtos p INNER JOIN ItensVenda iv ON p.ProdutoID = iv.ProdutoID INNER JOIN Vendas v ON iv.VendaID = v.VendaID WHERE YEAR(v.DataVenda) = @Ano AND MONTH(v.DataVenda) = @Mes GROUP BY p.ProdutoID, p.NomeProduto; UPDATE @Relatorio SET MediaVendasDiaria = TotalVendas / DAY(EOMONTH(CAST(CAST(@Ano AS VARCHAR) + \u0026#39;-\u0026#39; + CAST(@Mes AS VARCHAR) + \u0026#39;-01\u0026#39; AS DATE))); RETURN; END; GO -- Usage example SELECT * FROM dbo.ObterRelatorioVendasMensal(2023, 7); When should you use an mTVF? Only when the logic is truly complex and can\u0026rsquo;t be expressed concisely in an iTVF, and after considering other options such as views, CTEs or procedures that return results.\nEssential Best Practices Avoid Scalar Functions on Columns of Large Tables in WHERE or JOIN Clauses: This prevents index use and forces a table scan. For example, WHERE dbo.MinhaFuncao(Coluna) = 'Valor' is a recipe for performance problems. Prefer iTVFs over mTVFs: Whenever possible, shape your logic to fit an Inline Table-valued Function so you benefit from SQL Server\u0026rsquo;s optimizations. Keep the Logic Simple: Overly complex functions become hard to debug and maintain, on top of potential performance issues. Use Proper Schemas: Always prefix your functions with the right schema (e.g., dbo.MinhaFuncao). Understand the Impact on Optimization: Functions can \u0026ldquo;hide\u0026rdquo; intent from the query optimizer, leading to suboptimal execution plans. Use SET STATISTICS IO ON and SET STATISTICS TIME ON, and analyze the execution plan to understand what\u0026rsquo;s going on. Test, Test, Test!: Test your functions with different data volumes and scenarios to make sure they perform well and return the expected results. Functions are a core part of any SQL Server developer\u0026rsquo;s toolkit. Used correctly, they can greatly improve the efficiency and maintainability of your code. But remember: with great power comes great optimization responsibility!\nHave you run into an interesting challenge with functions in SQL Server? Share your experience in the comments!\n","date":"2025-07-27T12:00:00-03:00","permalink":"https://alencarinosql.com.br/en/p/funcoes-sql-server/","title":"SQL Server Functions"},{"content":"Configuring Logins in SQL Server Introduction Configuring logins in SQL Server is one of the essential tasks for making sure access to the database is properly controlled. There are two main kinds of logins in SQL Server: SQL Server logins and Windows logins. In this post, we\u0026rsquo;ll look at how to set up both kinds of logins and go over recommended practices for managing user access.\n1. Creating SQL Server Logins In SQL Server, you can create logins through Management Studio or with T-SQL. Let\u0026rsquo;s start with a basic example of how to create a SQL Server login:\n1 CREATE LOGIN NovoUsuario WITH PASSWORD = \u0026#39;SenhaSegura123\u0026#39;; This command creates a login named NovoUsuario with an associated password. After creating it, you need to grant permissions to this login. That\u0026rsquo;s done by associating it with a user account inside a specific database.\nExample of creating a login with password expiration settings: 1 2 3 4 CREATE LOGIN NovoUsuario WITH PASSWORD = \u0026#39;SenhaSegura123\u0026#39;, CHECK_POLICY = ON, CHECK_EXPIRATION = ON; In this example, the password policy and password expiration are enabled, forcing the user to change the password after the set period.\n2. Creating Windows Logins You can also create Windows-based logins, letting users access the database with their operating system credentials:\n1 CREATE LOGIN [DOMINIO\\Usuario] FROM WINDOWS; In this case, the login is created using the Windows account DOMINIO\\Usuario.\nWindows Logins vs SQL Server Logins SQL Server logins: Useful in scenarios where users aren\u0026rsquo;t part of a domain, or when you need authentication that is exclusive to SQL Server. Windows logins: Recommended when domain security and user account administration are already handled at the operating system level. 3. Mapping Logins to Databases After creating the login, the next step is to map it to a database. That\u0026rsquo;s done by creating a database user for the login:\n1 2 USE MeuBancoDeDados; CREATE USER NovoUsuario FOR LOGIN NovoUsuario; The command above creates a user in the MeuBancoDeDados database mapped to the NovoUsuario login.\nExample of mapping a Windows login: 1 2 USE MeuBancoDeDados; CREATE USER [DOMINIO\\Usuario] FOR LOGIN [DOMINIO\\Usuario]; 4. Granting Permissions After mapping the login to the database, you need to grant the required permissions. For example, to grant read and write permissions:\n1 GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO NovoUsuario; This gives the NovoUsuario user read and write permissions on every table in the dbo schema.\nExample of granting permissions to Windows logins: 1 GRANT EXECUTE ON SCHEMA::dbo TO [DOMINIO\\Usuario]; In this case, the Windows login [DOMINIO\\Usuario] gets permission to execute stored procedures in the dbo schema.\n5. Security Considerations Strong passwords: Always use strong passwords for SQL Server logins. Weak passwords are one of the main attack vectors. Least privilege: Avoid logins with administrative permissions unless absolutely necessary. Follow the principle of \u0026ldquo;least privilege\u0026rdquo;. Windows logins: Whenever possible, use Windows logins, because they take advantage of the operating system\u0026rsquo;s security and authentication controls. Auditing: It\u0026rsquo;s important to set up security auditing to monitor login activity, such as failed login attempts and logins with elevated privileges. Conclusion Configuring logins in SQL Server is a fundamental task for ensuring security and access control over your data. By creating the right logins and applying security best practices, such as strong passwords and minimal permissions, you protect your database environment against unauthorized access. It\u0026rsquo;s also important to review permissions regularly and make sure logins are kept up to date and in line with your organization\u0026rsquo;s security policies.\n","date":"2025-07-26T12:00:00-03:00","image":"https://alencarinosql.com.br/p/logins-sql-server/1_hu_7a63d7ea16516fb7.jpg","permalink":"https://alencarinosql.com.br/en/p/logins-sql-server/","title":"SQL Server Logins"},{"content":"🚀 Power BI News – July 2025 🆕 Main Highlights Improved integration with Microsoft 365 Makes collaboration and the use of business features easier. Smarter Copilot Generates automated, contextual insights. Support for Power BI Report Server and SQL Server 2025 Improves on-premises report distribution. 🛠️ Technical Updates – Power BI Desktop Current version: 2.144.1378.0 Release date: July 3, 2025\n🔧 June 2025 QFE 3 Fixed an error when refreshing tables with an outdated model.abf. Improved Copilot error message to point out an unsupported region. 🔧 June 2025 QFE 1 Fix for incremental refresh validation with multiple sources. High-contrast UI adjustments in the \u0026ldquo;Manage Relationships\u0026rdquo; dialog. Fix for conditional formatting that removed colors by mistake. 📹 Official Video Watch the video with the main new features on the official Power BI channel:\n➡️ Power BI Update – July 2025 Feature Summary\n📌 Quick Summary Category Update Microsoft 365 Improved integration Copilot Smarter and more contextual Report Server Support for PBIRS and SQL Server 2025 Fixes Stability in refresh, UI and visuals Current version 2.144.1378.0 – July 3, 2025 📥 Recommended Update The July version is the latest and the recommended one. 👉 Click here to download Power BI Desktop\nMore details are available in the full change log.\nSource: Power BI Desktop – Latest Update\n","date":"2025-07-25T12:00:00-03:00","permalink":"https://alencarinosql.com.br/en/p/novidadespowerbijulho2025/","title":"Power BI News – July 2025"}]