ARTICLE

How to Create Shapes in SQL Server 2012

Posted by Vipendra Verma Articles | SQL Server 2012 August 22, 2012
In this article I am going to explain how to create a shape in SQL server 2012.
Reader Level:

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

Login to add your contents and source code to this article
comments
COMMENT USING
PREMIUM SPONSORS
Nevron Software is a global leader in component based data visualization technology for a diverse range of Microsoft centric platforms. Nevron Data Visualization components are used by many companies, educational and government organizations around the world.
Nevron Chart
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Nevron Chart