Monday, November 29, 2021

Manufacturer information inside SQL server

How to Identify Your System's Manufacturer and Model from the SQL Server Error Log

Did you know you can quickly pinpoint your SQL Server's system manufacturer and model number directly from its error log? It's a handy trick, especially when you need to gather system details without digging deep into system properties.

Using a Simple SQL Query

Here's the straightforward SQL query you can use:

EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer';

This command searches the current SQL Server error log for entries containing the word "Manufacturer." The output will typically include a line detailing your system's make and model.

Important Considerations

Keep in mind that this query will only yield results if the error log hasn't been recycled since your SQL Server instance last started. If the log has cycled, the relevant information might no longer be present in the current log.

Verifying Virtual Machine Environments

Beyond just identifying the manufacturer, this method can also be used to confirm if your SQL Server is running within a virtual machine (VM). Many virtualized environments will clearly state "Virtual Machine" or similar in their manufacturer details.

Further Reading and Resources

For more advanced techniques on working with SQL Server error logs and system information, check out these related posts:

Saturday, November 20, 2021

Determine which scalar UDFs are in-lineable

When you're working with SQL Server, understanding the properties of your functions can be really helpful for performance optimization. The following SQL query helps you identify your scalar user-defined functions (UDFs) and check if they are "inlineable."

Check if Your SQL Scalar Functions are Inlineable

This query provides insight into whether a scalar UDF can be inlined, which can significantly improve query performance by essentially expanding the function's logic directly into the calling query, avoiding the overhead of a function call.

SELECT OBJECT_NAME(m.object_id) AS [Function Name]
 ,is_inlineable
 ,inline_type
FROM sys.sql_modules AS m WITH (NOLOCK)
LEFT OUTER JOIN sys.dm_exec_function_stats AS efs WITH (NOLOCK) ON m.object_id = efs.object_id
WHERE efs.type_desc = N'SQL_SCALAR_FUNCTION'
OPTION (RECOMPILE);

For more detailed information on scalar UDF inlining and related system views, you can refer to the official Microsoft documentation:

Saturday, November 13, 2021

How to check what databases are accessible?


Ever wonder which databases you can actually get into? There's a simple SQL query that'll show you exactly which ones are accessible on your system. It's a quick way to check your database permissions at a glance.


SELECT name, HAS_DBACCESS(name) FROM sys.databases;

This statement lists each database by name and tells you whether you have access to it. Pretty handy for a quick security check!



Popular Posts