Stairway to T-SQL: Beyond The Basics Level 1: The TOP Clause
The first topic in this stairway will be discussing the TOP clause. The TOP clause allows you to control the number of rows to be returned or affected by a query.
The first topic in this stairway will be discussing the TOP clause. The TOP clause allows you to control the number of rows to be returned or affected by a query.
In this level of the Beyond the T-SQL Basics stairway, we will be discussing the different aspects of a subquery.
This level discusses how to use a database VIEW to simplify your Transact-SQL(T-SQL) code. By understanding how to use a VIEW you will be able to better support writing T-SQL code to meet complex business requirements. In this article I will be discussing what a database VIEW is and then providing a number of examples to help you understand how you can use a VIEW to implement different coding scenarios.
There are times when retrieving data for complex business requirement requires you to temporarily store one or more results sets for a short period of time. Typically these temporary tables are stored in the scope of the current connection, but they may also need to be available across multiple connections.
There are times where you need to write a single T-SQL statement that is able to return different T-SQL expressions based on the evaluation of another expression. When you need this kind of functionality you can use the CASE expression or IIF function to meet this requirement. In this Stairway level Gregory Larsen reviews the CASE and IIF syntax and showing you examples of how the CASE expression and IIF function.
No one wants to use more keystrokes than they have to when they write a chunk of T-SQL code. To help with minimizing the number of characters a T-SQL developer needs to type the Microsoft team introduced three new shortcuts operators when they release SQL Server 2008. These shorts cuts are the String Concatenation, Add EQUALS, and the Subtract EQUALS operators.
There times when you need to write T-SQL code that creates specific T-SQL Code and executes it. When you do this you are creating dynamic T-SQL code. When writing dynamic T-SQL you need to understand how dynamic code opens the possibilities for a SQL injection attack.
In this level, Rob Sheldon explains what XML is, and describes the components of an XML document, Elements and Attributes. He explains the basics of tags, entity references, enclosed text, comments and declarations
Robert Sheldon describes SQL Server's XML Data Type, and shows that it is as easy to configure a variable, column, or parameter with the XML data type as configuring one of these objects with any other datatype
You can extract a subset of data from an XML instance by using the query() method, and you can use the value() method to retrieve individual element and attribute values from an XML instance.
By Brian Kelley
But as I've matured over the years, I came to realize that I needed...
By alevyinroc
I will be presenting my latest session, Documenting Your Work for Worry-Free Vacations, in-person...
By Steve Jones
I saw a question asking about the next sequence value and decided to try...
I've got a table with 186,703,969 rows, about 300GB of data. There are several...
I created a SQL Database in Azure Portal but I've just noticed it also...
Comments posted to this topic are about the item An Unusual Identity
What values are returned when I run this code?
CREATE TABLE dbo.IdentityTest2
(
id NUMERIC(10,0) IDENTITY(10,10) PRIMARY KEY,
somevalue VARCHAR(20)
)
GO
INSERT dbo.IdentityTest2
(
somevalue
)
VALUES
( 'Steve')
, ('Bill')
GO
SELECT top 10
id
FROM dbo.IdentityTest2 See possible answers