sql defrag 

SQL Server Function to Generate Random Numbers

By: Eli Leiba   |   Read Comments   |   Related Tips: More > T-SQL Problem The request is to expand upon the SQL Server randomizing capabilities by creating a function that will generate a random number in many different ways, thus enabling the user to choose the randomizing generation approach from four different methods.  Solution My solution involves creating a T-SQL function in the SQL Server master database, called GenRandomNumber. This function gets a parameter called @method…

Read More
sql defrag 

Custom Intrusion Detection Reporting for SQL Server

By: Svetlana Golovko   |   Read Comments   |   Related Tips: More > Auditing and Compliance Problem Using Windows Authentication with SQL Server is the recommended (more secure) authentication mode. Windows Authentication uses Kerberos security protocol, passwords are not transferred through the network and Windows Authentication offers additional password policies that are not available for SQL Server logins. Some applications still require SQL Server logins for user authentication or for application service accounts. Read more about the advantages…

Read More
sql defrag 

Determine SQL Server Network Protocol Information using T-SQL and DMVs

By: Eduardo Pivaral   |   Read Comments   |   Related Tips: More > Functions – System Problem You need to determine the network protocols and the enabled/disabled status in your SQL Server instances, but for whatever reason, you cannot access SQL Server configuration manager, or maybe you just want to know that information without having to login to the server, so you need a quick, reliable way to determine this information using T-SQL.  Also, you may need to know…

Read More
sql defrag 

How Contributing to Your Tech Community Reaps a Multitude of Career Benefits

By: Erica Woods   |   Read Comments   |   Related Tips: More > Professional Development Branding Problem Most people want to give back to their communities, whether that be through sharing knowledge, acting as a mentor, volunteering, etc., yet they are not exactly sure where to provide value!  They also don’t realize all of the many strong career benefits of becoming a contributor vs. being a member.  Solution Want to further build your expertise?  Showcase your credibility?  …

Read More
sql defrag 

How to Compare and Combine Artificial Intelligence Models with T-SQL

By: Rick Dobson   |   Read Comments   |   Related Tips: More > T-SQL Problem Please present some T-SQL code on comparing artificial intelligence models to guide decision-making. Also, demonstrate how to combine two models into a new model to reveal issues for combining models and to determine if a combined model performs better than its source models. Solution Previous tips in MSSQLTips.com demonstrated different approaches to calculating, with T-SQL, buy and sell recommendations for stocks with…

Read More
sql defrag 

Introduction to SQL Server Express User Instances

By: Daniel Farina   |   Read Comments   |   Related Tips: More > Express Edition Problem You may have heard about a feature of SQL Server Express called User Instances that allows users who are not administrators on their local computers to attach and connect to a SQL Server Express database.  In this tip I will explain to you what User Instances are and how you can take advantage of them. Solution Suppose you are a sysadmin or…

Read More
sql defrag 

Building SQL Server Indexes in Ascending vs Descending Order

By: Greg Robidoux   |   Read Comments (5)   |   Related Tips: More > Indexing Problem When building indexes often the default options are used to create an index which creates the index in ascending order.  This is usually the most logical way of creating an index, so the newest data or smallest value is at the top and the oldest or biggest value is at the end.  Although searching an index works great by creating an index this…

Read More
sql defrag 

SQL Server 2017 installation on Ubuntu using Docker

By: Rajendra Gupta   |   Read Comments   |   Related Tips: More > SQL Server on Linux Problem In this tip, we will learn how to install and run a SQL Server Linux container image using a Docker on the Ubuntu operating system. Solution SQL Server on Linux supports the same enterprise security capabilities that customers rely on with SQL Server on Windows. SQL Server 2017 supports the Linux operating system and can be used with the Docker…

Read More
sql defrag 

Change collation of an Azure SQL database by hacking the BACPAC file

By: Mohammed Moinudheen   |   Read Comments   |   Related Tips: More > Azure Problem We created an Azure SQL database using the default collation that was available. Now, there is a requirement to change the collation. Is it possible to change the collation of an Azure SQL database after it is created? Solution In the previous tip, you learned how to use the import and export option for the data-tier application to make the collation change…

Read More
sql defrag 

Minimally Logging Bulk Load Inserts into SQL Server

By: Greg Robidoux   |   Read Comments (3)   |   Related Tips: More > Import and Export Problem One of the advantages of using the Bulk-Logged recovery model is to minimally log bulk load commands, but still have other transactions fully logged.  You may find that when you set your recovery model to Bulk-Logged or to Simple and you run your bulk load commands that the size of your transaction log still grows quite large.  The reason for this…

Read More