How to Create Shapes in SQL Server 2012

Introduction

In this article I am going to explain how to create a shape in SQL Server 2012. SQL Server 2012 provides the ability to create shapes.

In SQL Server 2012 we can create various types of shapes like triangle, square, pentagon, hexagon, heptagon and octagon. You can create 2 different types of shapes based on your imagination.

First of all to create a shape we declare a variable using the DECLARE keyword. We create this variable as a geometry data type.

We complete declaration of the variable then we execute this variable. To execute this variable we use a SELECT statement.

Here we are creating a shape in SQL Server 2012.

Statement that creates a shape in SQL Server 2012:

DECLARE@Shape1 geometry = 'POLYGON ((-20 -30, -3 -26, 34 -33, 20 -40, -20 -30))'
SELECT
@Shape1

Output

Clipboard02.jpg

Statement that creates a square  in SQL Server 2012:

DECLARE@Shape2 geometry = 'POLYGON ((-10 -10, -10 10, 10 10, 10 -10, -10 -10))'
SELECT
@Shape2

Output

Clipboard04.jpg

Statement that create triangle  in SQL Server 2012:

DECLARE@Shape3 geometry = 'POLYGON ((-10 -10, 0 10, 10 -10, -10 -10))'
SELECT
@Shape3

Output

Clipboard06.jpg

Statement that create two shape in SQL Server 2012:

DECLARE@Shape1 geometry = 'POLYGON ((-20 -30, -3 -26, 34 -33, 20 -40, -20 -30))'
DECLARE
@Shape2 geometry = 'POLYGON ((-18 -20, 0 -10, 6 -12, 10 -20, 2 -22, -18 -20))'
SELECT
@Shape1
UNION
ALL
SELECT
@Shape2

Output

Clipboard09.jpg


Similar Articles