dbfiddle

Background

Reading through online SQL discussions and found out about db<>fiddle.

Code

Here is a sample code.


set nocount on;
SET STATISTICS XML OFF;

if object_id('[dbo].[customer_dadeniji]') is not null
begin

    drop table [dbo].[customer_dadeniji]

end

if object_id('[dbo].[customer_dadeniji]') is null
begin

    CREATE TABLE [dbo].[customer_dadeniji]
    (
       [id] [INT] NOT NULL
                  identity(1,1),

       [guid] uniqueidentifier NULL,

        [CHAR](6) NULL,

       [firstName] [VARCHAR](100) NULL
            INDEX [IX_FirstName] NONCLUSTERED,

       [lastName] [VARCHAR](100) NULL
            INDEX [IX_LastName] NONCLUSTERED,

       [address1] [VARCHAR](150) NULL,

       [address2] [VARCHAR](150) NULL,

       [zipCode] [CHAR](5) NULL,

       [countryCode] [CHAR](3) NULL
            INDEX [IX_CountryCode] NONCLUSTERED,

       [lastPurchaseDate] [DATE] NULL,

       [totalPurchasesAmount] [FLOAT] NULL,

       constraint [PK_Customer_dadeniji]
       primary key
       (
          [id]
       )
    );

end

INSERT INTO [dbo].[customer_dadeniji]
(
    [lastname]
  , [guid]
)
SELECT
        tblSO.[name]
      , NEWID()

FROM sys.objects tblSO

INSERT INTO [dbo].[customer_dadeniji]
(
    [lastname]
  , [guid]
)
SELECT
        'smith'
      , CAST(NEWID() AS VARCHAR(50))

SET STATISTICS XML ON
;

select [lastname]

from   [dbo].[customer_dadeniji] 

where  [lastname] = 'smith'

drop table [dbo].[customer_dadeniji];

SET STATISTICS XML OFF
;

db<>Fiddle

URL

dbFiddle is available here.

Database Platform Supported

As of 2019-07-07, here are some of the database platforms supported :-

dbSupport.20190707.0815PM

SQL Server

SQL Server - v2017

Sample Code

Our little sample code is available here.

Image

dbo.customer.20190707.0807PM

Explanation

We see the query and results of issuing the run command.

The query's output includes both the data returned and query plan.

We have the query plan because we invoked "SET STATISTICS XML ON" before issuing our select clause.

One thought on “dbfiddle

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s