SQL Server inline table-valued functions
August 29, 2019In this article series, we will find basics and common usage scenarios about the inline table-valued functions and we will also be consolidating your learnings with practical examples.
In this article series, we will find basics and common usage scenarios about the inline table-valued functions and we will also be consolidating your learnings with practical examples.
APX1088 – Parameters names not specified explicitly Description: This rule evaluates the T-SQL script for executing a stored procedure without referencing parameters explicitly by name. Although it is possible, it is considered a best practice to provide the names of the parameters. For more information visit https://docs.microsoft.com/en-us/sql/relational-databases/stored-procedures/execute-a-stored-procedure?view=sql-server-2017 Example script:
1 2 3 4 5 6 7 8 |
EXEC proc_ListAllParam 12345, 54321, 32145; EXEC proc_ListAllParam @FirstNumeber = 12345, @SecondNumeber = 54321, @ThirdNumeber = 32145; |
Message: Explicitly named parameters not […]
APX1090 – Avoid Select(*) Description: This rule evaluates the T-SQL script for using “SELECT *”. Avoid using SELECT * in your script unless it is required. Always explicitly list the columns in a query to create more maintainable and predictable code. For more information visit https://stackoverflow.com/questions/321299/what-is-the-reason-not-to-use-select Example script:
1 2 3 4 5 6 7 |
SELECT * FROM FirstTable; SELECT a, b, c FROM SecondTable; UPDATE ThirdTable SET a = 0; SELECT * FROM FourthTable; |
Message: Statement contains SELECT * APX1091 […]
APX1092 – HAVING with non-aggregate functions Description: This rule evaluates the T-SQL script for using HAVING with non-aggregate functions. HAVING should be used only with aggregate functions. For more information visit https://www.techonthenet.com/sql/having.php Example script:
1 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 |
SELECT DataVal, MAX(price) FROM FirstFailedTable GROUP BY DataVal HAVING DataVal LIKE '%abc%'; SELECT DataVal, MAX(price) FROM SecondFailedTable GROUP BY DataVal HAVING DataVal LIKE '%def%'; SELECT DataVal, MAX(price) FROM ThirdFailedTable GROUP BY DataVal HAVING DataVal LIKE '%111%'; SELECT DataVal, MAX(price) FROM FirstGoodTable GROUP BY DataVal HAVING SUM(ID) < 20; SELECT DataVal, MAX(price) FROM SecondGoodTable GROUP BY DataVal HAVING SUM(ID) < 200; |
Message: HAVING clause is used in a non aggregate function APX1096 – Comparison with NULL Description: This rule evaluates the […]
APX1129 – Index type not specified explicitly Description: This rule evaluates the T-SQL script for NOT specifying the Index types, CLUSTERED or NONCLUSTERED explicitly. If not specified, the CREATE INDEX statement will be used to create non-clustered index. It is recommended to specify the type of the index as Clustered or Non-clustered in the CREATE […]
In this article, we will explore SQL Server ALTER TABLE ADD Column statements to add column(s) to an existing table. We will also understand the impact of adding a column with a default value and adding and updating the column with a value later on larger tables.
APX1094 – Non-ANSI outer join Description: This rule evaluates the T-SQL script for using Non-ANSI outer join syntax e.g. *=, =* that has been deprecated. Use ANSI OUTER JOIN statement instead. For more information visit https://docs.microsoft.com/en-us/sql/sql-server/install/outer-join-operators-and-are-not-supported-in-90-or-later-compatibility-modes?view=sql-server-2014 Example script:
1 2 3 4 5 6 7 8 9 10 11 |
SELECT * FROM Employee, Department WHERE Employee.DepartmentID *= Department.DepartmentID; SELECT * FROM Employee, Department WHERE Employee.DepartmentID =* Department.DepartmentID; SELECT * FROM Employee, Department, Person WHERE Employee.DepartmentID =* Department.DepartmentID AND Employee.PersonID *= Person.ID; SELECT * FROM Employee LEFT OUTER JOIN Departmen ON Employee.DepartmentID = Department.DepartmentID; SELECT * FROM Employee RIGHT OUTER JOIN Departmen ON Employee.DepartmentID = Department.DepartmentID; SELECT * FROM Employee FULL OUTER JOIN Department ON Employee.DepartmentID = Department.DepartmentID; |
Message: Statement uses Non-ANSI outer join APX1119 – String = expression_alias Description: This rule evaluates the […]
APX1086 – Check syntax errors Description: This rule evaluates the T-SQL script for any syntax error, by parsing the T-SQL statement and show any errors. It is recommended to check the documentation for each T-SQL statement in order to use it in the query properly. For more information visit https://www.tsql.info/ Example script:
1 2 3 4 5 6 7 8 9 10 11 |
SELECT * from FirstTable; SELECT * frm SecondTable; SELECT * form ThirdTable; DELETE from FourthTable wher id > 0; SELECT * from FifthTable; SELECT q from SixthTable; |
Message: Incorrect […]
Code APX1086 – Check syntax errors APX1095 – GOTO Usage APX1112 – Semi-colons statement terminator APX1113 – Uninitialized variable APX1114 – Unused parameter APX1123 – SET NOCOUNT OFF Usage APX1131 – Un-closed cursor APX1132 – Cursor not deallocated APX1133 – RAISERROR with severity above 18 missing WITH LOG clause APX1136 – Direct use of Date-Time […]
Have you ever noticed SET NOCOUNT ON statement in T-SQL statements or stored procedures in SQL Server? I have seen developers not using this set statement due to not knowing it.
Database administrators should be aware of the internal SQL Server processes such as the dirty pages, SQL Server CHECKPOINT, Lazy writer process. This is a very common question that you might come across in SQL DBA technical interviews as well on all levels such as beginner, intermediate and expert level.
This article gives an overview of the KILL SPID command and how to monitor the rollback progress.
In this article, we will learn usage details of the sp_updatestats built-in store procedure which helps to update all statistics in a SQL Server database. First of all, we will take a glance at the statistics concept in SQL Server.
SQL Server Query Store is a performance monitoring tool that helps us evaluate the performance of a SQL query in terms of several different performance metrics such as CPU and Memory Consumption, execution time and the I/O cycles consumed by the query. Query store is similar to the windows “Task Manager”. A task manager provides […]
A graph database is a type of NoSQL database that is based on graph theory. Graph databases are ideal for storing data that has complex many to many relationships. In this article, we will study the very basics of graph databases with the help of a simple example.
This article explores the SSIS Conditional Split Transform task to split data into multiple destinations based on the specified conditions.
Replication is a process to manage multiple copies of the same data at a different node. Microsoft SQL Server supports Merge Replication, Transaction Replication, Peer to Peer Replication and Snapshot Replication.
In this article, we will review how to construct and execute dynamic SQL statements in SQL Server with different examples.
This article explores the usage of TempDB and different ways to shrink the TempDB database in SQL Server
This article gives a walk-through of SQL Server Statistics and different methods to perform SQL Server Update Statistics.
Performance monitoring is a must to do the task for a DBA. You should ensure that the database performance is optimal all the time without any impact on the databases. Performance issues act like an open stage, and you need to look at every aspect such as CPU, RAM, server performance, database performance, indexes, blocking, […]
Introduction In this article, I’ll explore the use of snapshot isolation using row versioning as an alternative to the classic ANSI SQL transaction levels.
As SQL professionals, we often have to deal with XML data in our databases. This article will help you walk through several examples of using ‘FOR XML PATH’ clause in SQL Server.
In this article, we will demonstrate T-SQL metadata functions available in the SQL Server.
In this article, we will learn how to create stored procedures in SQL Server with different examples.
© Quest Software Inc. ALL RIGHTS RESERVED. | GDPR | Terms of Use | Privacy