<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sarvesh Pandey on Medium]]></title>
        <description><![CDATA[Stories by Sarvesh Pandey on Medium]]></description>
        <link>https://medium.com/@sarveshpandey23?source=rss-59fb5955aac6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HiHziQzcHrywYv9E</url>
            <title>Stories by Sarvesh Pandey on Medium</title>
            <link>https://medium.com/@sarveshpandey23?source=rss-59fb5955aac6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 10:17:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sarveshpandey23/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SNOWPIPE on Snowflake for Azure Storage Account]]></title>
            <link>https://sarveshpandey23.medium.com/snowpipe-on-snowflake-for-azure-storage-account-735723bacb92?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/735723bacb92</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[snowpipe]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Mon, 15 Aug 2022 21:49:23 GMT</pubDate>
            <atom:updated>2022-08-17T06:46:26.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJKH9c1uKOBwmzQjHKMYTw.png" /><figcaption>SNOWPIPE on Snowflake for Azure Storage Account</figcaption></figure><p><strong>What is SnowPipe?</strong></p><p><a href="https://docs.snowflake.com/en/user-guide/data-load-snowpipe-intro.html">SnowPipe</a> is a method to load data from Other External Data Source like Azure Storage Account or Amazon S3 bucket to Snowflake Staging Environment or Layer.</p><p>This article will help you to create and understand working of SnowPipe, How its load data and what are its limitations.</p><p><strong>Prerequisite </strong>–</p><p><strong><em>Azure Portal Subscription AD Access</em></strong></p><p><strong><em>Azure Storage Account (Blob/DataLake Storage)</em></strong></p><p><strong><em>Azure Storage Queue</em></strong></p><p><strong><em>SnowFlake Admin access</em></strong></p><h4>Steps to Pull Data from Azure Storage Account to Snowflake –</h4><p>Step 1 — We assume you already have/created Azure Storage Account (Blob/DataLake Storage) and Azure Storage Queue</p><p>Step 2 — Create Event Grid for Azure Storage Account</p><p>After clicking on “+ Event Subscription”, Fill the details as per requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*-HWJjCyOFGRHAV3i6kC8NA.png" /><figcaption>SNOWPIPE on Snowflake for Azure Storage Account</figcaption></figure><p>Once its created, we need to connect to Snowflake</p><p>Step 3 — Create Integration in snowflake</p><p>Integration help snowflake to get information of source file location and additional required details. Its store address of source.</p><p>— CREATE INTEGRATION</p><p><em>create notification integration SNOWPIPE_DEMO_EVENT</em></p><p><em>enabled = true</em></p><p><em>type = queue</em></p><p><em>notification_provider = azure_storage_queue</em></p><p><em>azure_storage_queue_primary_uri = ‘https://sarvesh123.queue.core.windows.net/snowpipe-source-pipe&#39;</em></p><p><em>azure_tenant_id = ‘ec4266b8-****-****-****-633f321ac240’; //AZURE AD -&gt; PROPERTY</em></p><p>show integrations — Integrations Details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*EIRGhYJkdQzhVH4ov6E7_A.png" /><figcaption>SNOWPIPE on Snowflake for Azure Storage Account</figcaption></figure><p><em>DESC notification integration SNOWPIPE_DEMO_EVENT;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*wIN26RT5U1T8P0KessRjWg.png" /><figcaption>SNOWPIPE on Snowflake for Azure Storage Account</figcaption></figure><p>Step 4 — Go to Azure Portal -&gt; Azure Active Directory -&gt; ENTERPRISE APPLICATION -&gt; Search for SnowFlake application</p><p>Step 5 — OPEN STORAGE ACCOUNT -&gt; IAM (Access Roles) -&gt;Click on ADD ROLE -&gt; Search for Storage Queue Data Contributor Role -&gt; On SNOWFLAKE Application (Searched in AAD)</p><p>Step 6 — Open Storage Account -&gt; Under Security and Networking -&gt; Shared Access Signature</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*k-6zCyFctWwcLTotu7ZJYg.png" /><figcaption>SNOWPIPE on Snowflake for Azure Storage Account</figcaption></figure><p>Checked Container and Object so Snowflake have access on Container and Data Files(Object)</p><p>After completing above actions, click on “Generate SAS and connection string”</p><p>Step 7 — Connect to SnowFlake and create Stage Environment. This will the first layer in snowflake which holds RAW data coming from source directly.</p><p>CREATE DATABASE SNOWPIPE_DEMO;</p><p>CREATE OR REPLACE STAGE “SNOWPIPE_DEMO”.”PUBLIC”.”DEMO_STAGE”</p><p>url = ‘azure://sarvesh123.blob.core.windows.net/csv/’ — <a href="https://sarvesh123.blob.core.windows.net/csv/">https://sarvesh123.blob.core.windows.net/csv/</a> replace https with azure</p><p>credentials = (azure_sas_token= ‘?sv=2021–06–08&amp;ss=bfqt&amp;srt=co&amp;sp=rwdlacupyx&amp;se=2022–08–15T14:04:43Z&amp;st=2022–08–15T06:04:43Z&amp;spr=https&amp;sig=ZAUv3z************gCNem06pggLhXC1WWzRY%3D’);</p><p>// SAS KEY with object and SAS key created in Step 6</p><p>ls @”SNOWPIPE_DEMO”.”PUBLIC”.”DEMO_STAGE”; — file name present in respective blob storage</p><p>Step 7 — CREATE SNOWPIPE</p><p>CREATE or REPLACE TABLE snowpipe_demo.public.employee(</p><p>id STRING,</p><p>name STRING</p><p>)</p><p>— CREATE A CSV FILE WITH SOME RECORDS or sample file with same column name as table</p><p>// Command to create SNOWPIPE</p><p><em>create or replace pipe snowpipe_demo.public.demo_pipe</em></p><p><em>auto_ingest = TRUE</em></p><p><em>integration = ‘SNOWPIPE_DEMO_EVENT’</em></p><p><em>as</em></p><p><em>COPY INTO snowpipe_demo.public.employee</em></p><p><em>from @”SNOWPIPE_DEMO”.”PUBLIC”.”DEMO_STAGE”</em></p><p><em>file_format = (type = ‘CSV’);</em></p><p>show pipes — Display list of Snowpipe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*PT7mFXxepq9gQHBQXkZjvg.png" /><figcaption>SNOWPIPE on Snowflake for Azure Storage Account</figcaption></figure><p>Step 8 — Manual refresh of SnowPipe which means this steps will load the data or you can say Run the SnowPipe to pull the records.</p><p>alter pipe snowpipe_demo.public.demo_pipe refresh;</p><p>select * from snowpipe_demo.public.employee</p><p>Step 9 — As Step 8 was a Manual Process, we will now try to automate the SnowPipe refresh by creating a Task that is nothing but a Job.</p><p><em>CREATE OR REPLACE TASK SNOWPIPE_REFRESH_TSK</em></p><p><em>WAREHOUSE = COMPUTE_WH</em></p><p><em>SCHEDULE = ‘2 MINUTE’</em></p><p><em>AS</em></p><p><em>alter pipe snowpipe_demo.public.demo_pipe refresh;</em></p><p><em>SHOW TASKS</em></p><p>Step 10 — To check SnowPipe Status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*SPnFODNjMVIfkG9aayY1hg.png" /><figcaption>SNOWPIPE on Snowflake for Azure Storage Account</figcaption></figure><p>Error Handlin<br>//VALIDATE PIPE ACTUALLY WORKING<br><em>select system$pipe_status(‘demo_pipe_1’)</em></p><p>//SNOWPIPE ERROR MESSAGE<br><em>select * from table(validate_pipe_load(PIPE_NAME =&gt; ‘demo_pipe_1’ , START_TIME =&gt; dateadd(HOUR,-2,current_timestamp())))</em></p><p>// COPY History from table to see error message<br><em>select * from table(INFORMATION_SCHEMA.COPY_HISTORY(TABLE_NAME =&gt; ‘snowpipe_demo.public.employee_1’ , START_TIME =&gt; dateadd(HOUR,-2,current_timestamp())))</em></p><p><strong>//MANAGE PIPE</strong><br>DESC PIPE snowpipe_demo.public.demo_pipe_1</p><p>SHOW PIPE</p><p>SHOW PIPE IN DATABASE MANAGE_DB</p><p>SHOW PIPE IN SCHEMA MANAGE_DB.PIPES</p><p>SHOW PIPE LIKES ‘%demo%’</p><p><strong>Advantage </strong>-</p><ol><li>Once the file get uploaded it won’t re-upload. This will not lead for duplications.</li><li>Execution time is quick</li><li>Each load is atomic and Query can be schedule to make this process automatic</li><li>Use Step 10 to check the status of Pipe as per the file name present in Azure storage</li></ol><p><strong>Limitations </strong>-</p><ol><li>If the existing file name got change(distinct) it will upload the data and cause duplication. (Use indicator and Data time column to remove this limitation)</li><li>If exiting record get updated and process through a new File it will upload it to the table.(Use indicator and Data time column to identify updated record)</li><li>Need to check SAS key if pipe doesn’t load data and pipe get failed</li></ol><ul><li><a href="https://sarveshpandey23.medium.com/loading-semi-structure-and-unstructured-data-in-snowflake-813308010ef1">Loading Semi-structure and Unstructured Data in Snowflake</a></li><li><a href="https://sarveshpandey23.medium.com/database-in-snowflake-dc9fd94f4703">Database in Snowflake</a></li></ul><p><a href="https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e">Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium | Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=735723bacb92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loading Semi-structure and Unstructured Data in Snowflake]]></title>
            <link>https://sarveshpandey23.medium.com/loading-semi-structure-and-unstructured-data-in-snowflake-813308010ef1?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/813308010ef1</guid>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[unstructured-data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Sat, 13 Aug 2022 11:43:51 GMT</pubDate>
            <atom:updated>2022-08-13T11:43:51.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*gYbaTq1-_z0oBr5A.jpeg" /><figcaption>Loading Semi-structure and Unstructured Data in Snowflake</figcaption></figure><p>Semi-Structured data — <br> Semi-structured data is information that does not reside in a relational database but that has some organizational properties that make it easier to analyze. With some processes, you can store them in the relation database (it could be very hard for semi-structured data), but Semi-structured exist to ease space. Example: XML data.</p><p>Unstructured data — <br> Unstructured data is a data which is not organized in a predefined manner or does not have a predefined data model; thus it is not a good fit for a mainstream relational database. So for Unstructured data, there are alternative platforms for storing and managing, it is increasingly prevalent in IT systems and is used by organizations in a variety of business intelligence and analytics applications. Example: Word, PDF, Text, Media logs.</p><p>Now above two points gives a clear picture about Semi-structure and Unstructured Data. Okay, but the question arises here “If it’s a data, How can we process it? How can we get information from it?”</p><p>This article and article series will help you to understand and answer this question.</p><p>Initially, Semi-structure and Unstructured Data are stored in either in FILES or Streaming data and we have to some how load it into snowflake then we can perform all the process and visualization easily.</p><p>Steps to Load data in Snowflake. NOTE — This architecture will follow weather its Snowflake or any other service.</p><p>1. Create Stage</p><p>2. Load Raw data</p><p>3. Analyze and Parse</p><p>4. Flatten Load</p><p>To handles these types of data we use Data type — <strong>Variant</strong> which handles unstructured data</p><p>Data type — Variant Handles unstructured data</p><blockquote>// create stage</blockquote><blockquote>CREATE OR REPLACE STAGE MANAGE_DB.EXTERNAL_STAGES.JSONSTAGE</blockquote><blockquote>URL = ‘s3://bucketsnowflake-jsondemo’</blockquote><blockquote>//create json file format</blockquote><blockquote>CREATE OR REPLACE file format MANAGE_DB.FILE_FORMATS.JSONFORMAT</blockquote><blockquote>TYPE = JSON;</blockquote><blockquote>//create target table with VARIANT data type (single column)</blockquote><blockquote>CREATE OR REPLACE table OUR_FIRST_DB.PUBLIC.JSON_RAW (</blockquote><blockquote>raw_file variant);</blockquote><blockquote>//Loading data into target table</blockquote><blockquote>COPY INTO OUR_FIRST_DB.PUBLIC.JSON_RAW</blockquote><blockquote>FROM @MANAGE_DB.EXTERNAL_STAGES.JSONSTAGE</blockquote><blockquote>file_format= MANAGE_DB.FILE_FORMATS.JSONFORMAT</blockquote><blockquote>files = (‘HR_data.json’);</blockquote><blockquote>SELECT * FROM OUR_FIRST_DB.PUBLIC.JSON_RAW</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Tig7F3o2cNY6gopbCmQn4g.png" /><figcaption>Loading Semi-structure and Unstructured Data in Snowflake</figcaption></figure><p>Now, this is what JSON looks like in single row or single records in RDBMS but this single records contains many information.</p><blockquote>{</blockquote><blockquote>“city”: “Bakersfield”,</blockquote><blockquote>“first_name”: “Portia”,</blockquote><blockquote>“gender”: “Male”,</blockquote><blockquote>“id”: 1,</blockquote><blockquote>“job”: {</blockquote><blockquote>“salary”: 32000,</blockquote><blockquote>“title”: “Financial Analyst”</blockquote><blockquote>},</blockquote><blockquote>“last_name”: “Gioani”,</blockquote><blockquote>“prev_company”: [],</blockquote><blockquote>“spoken_languages”: [</blockquote><blockquote>{</blockquote><blockquote>“language”: “Kazakh”,</blockquote><blockquote>“level”: “Advanced”</blockquote><blockquote>},</blockquote><blockquote>{</blockquote><blockquote>“language”: “Lao”,</blockquote><blockquote>“level”: “Basic”</blockquote><blockquote>}</blockquote><blockquote>]</blockquote><blockquote>}</blockquote><p>By looking the JSON structure, first question crosses our mind “How we going to retrieve data from JSON? What would be the format to pull required information?”</p><p>Follow the below format –</p><blockquote>SELECT COLUMN_NAME:NAME FROM TABLE WHERE CONDITION (NAME/VALUE FORMAT OF JSON)</blockquote><blockquote>SELECT RAW_FILE:city FROM OUR_FIRST_DB.PUBLIC.JSON_RAW</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*ZrUIvuDV15P5BL18rhEn2g.png" /><figcaption>Loading Semi-structure and Unstructured Data in Snowflake</figcaption></figure><blockquote>SELECT $1:first_name FROM OUR_FIRST_DB.PUBLIC.JSON_RAW //$1 REPRESENTS FIRST COLUMN</blockquote><blockquote>SELECT RAW_FILE:first_name::string AS FIRST_NAME FROM OUR_FIRST_DB.PUBLIC.JSON_RAW</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*03YFR82TGgf0__7osjqTwg.png" /><figcaption>Loading Semi-structure and Unstructured Data in Snowflake</figcaption></figure><blockquote>//handling array in JSON</blockquote><blockquote>SELECT RAW_FILE:prev_company as prev_company FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;</blockquote><blockquote>SELECT RAW_FILE:prev_company[1]::STRING as prev_company FROM OUR_FIRST_DB.PUBLIC.JSON_RAW;</blockquote><blockquote>//Dealing with hierarchy</blockquote><blockquote>select raw_file:spoken_languages from our_first_db.public.json_raw</blockquote><blockquote>select raw_file:spoken_languages[0] from our_first_db.public.json_raw</blockquote><blockquote>select raw_file:spoken_languages[0]:language from our_first_db.public.json_raw</blockquote><blockquote>FOR PARQUTE</blockquote><blockquote>//PARQUTE</blockquote><blockquote>CREATE OR REPLACE FILE FORMAT MANAGE_DB.FILE_FORMATS.PARQUET_FORMAT</blockquote><blockquote>TYPE = ‘parquet’;</blockquote><blockquote>CREATE OR REPLACE STAGE MANAGE_DB.EXTERNAL_STAGES.PARQUETSTAGE</blockquote><blockquote>url = ‘s3://snowflakeparquetdemo’</blockquote><blockquote>FILE_FORMAT = MANAGE_DB.FILE_FORMATS.PARQUET_FORMAT</blockquote><blockquote>LIST @MANAGE_DB.EXTERNAL_STAGES.PARQUETSTAGE;</blockquote><blockquote>SELECT * FROM @MANAGE_DB.EXTERNAL_STAGES.PARQUETSTAGE;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Bp6ic7TvhpuM0voRUfskYQ.png" /><figcaption>Loading Semi-structure and Unstructured Data in Snowflake</figcaption></figure><blockquote>{</blockquote><blockquote>“__index_level_0__”: 7,</blockquote><blockquote>“cat_id”: “HOBBIES”,</blockquote><blockquote>“d”: 489,</blockquote><blockquote>“date”: 1338422400000000,</blockquote><blockquote>“dept_id”: “HOBBIES_1”,</blockquote><blockquote>“id”: “HOBBIES_1_008_CA_1_evaluation”,</blockquote><blockquote>“item_id”: “HOBBIES_1_008”,</blockquote><blockquote>“state_id”: “CA”,</blockquote><blockquote>“store_id”: “CA_1”,</blockquote><blockquote>“value”: 12</blockquote><blockquote>}</blockquote><blockquote>SELECT $1:cat_id ,$1:__index_level_0__ FROM @MANAGE_DB.EXTERNAL_STAGES.PARQUETSTAGE WHERE $1:__index_level_0__ &gt; 100;</blockquote><blockquote>SELECT</blockquote><blockquote>$1:__index_level_0__::int as index_level,</blockquote><blockquote>$1:cat_id::VARCHAR(50) as category,</blockquote><blockquote>DATE($1:date::int ) as Date,</blockquote><blockquote>$1:”dept_id”::VARCHAR(50) as Dept_ID,</blockquote><blockquote>$1:”id”::VARCHAR(50) as ID,</blockquote><blockquote>$1:”item_id”::VARCHAR(50) as Item_ID,</blockquote><blockquote>$1:”state_id”::VARCHAR(50) as State_ID,</blockquote><blockquote>$1:”store_id”::VARCHAR(50) as Store_ID,</blockquote><blockquote>$1:”value”::int as value,</blockquote><blockquote>METADATA$FILENAME as FILENAME,</blockquote><blockquote>METADATA$FILE_ROW_NUMBER as ROWNUMBER,</blockquote><blockquote>TO_TIMESTAMP_NTZ(current_timestamp) as LOAD_DATE //NTZ IS A NO TIMEZONE FUNCTIONS</blockquote><blockquote>FROM @MANAGE_DB.EXTERNAL_STAGES.PARQUETSTAGE;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*u-rposu41wlDPUUybtAzxA.png" /><figcaption>Loading Semi-structure and Unstructured Data in Snowflake</figcaption></figure><p>What we have observed, loading data required a Stage table and Target table.</p><p>To load data between Stage and Target table we need copy script and use SQL query to pull the required information.</p><p><a href="https://sarveshpandey23.medium.com/copy-option-in-snowflake-dw-17209855cad9">Copy option in Snowflake DW. This article will help you to… | by Sarvesh Pandey | Jul, 2022 | Medium</a></p><p><a href="https://sarveshpandey23.medium.com/loading-data-in-snowflake-41be081fe812">Loading Data in Snowflake. So, on the previous blog we have… | by Sarvesh Pandey | Jun, 2022 | Medium</a></p><p><a href="https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e?source=your_stories_page-------------------------------------">https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e?source=your_stories_page-------------------------------------</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=813308010ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Copy option in Snowflake DW]]></title>
            <link>https://sarveshpandey23.medium.com/copy-option-in-snowflake-dw-17209855cad9?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/17209855cad9</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Mon, 04 Jul 2022 18:53:19 GMT</pubDate>
            <atom:updated>2022-07-04T18:53:19.257Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stpEzU7TFIpGu1MzAeUsUQ.jpeg" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>This article will help you to understand different feature/options available with Copy data command in Snowflake.</p><p>Understanding Copy Options -</p><p>Validation</p><p>Size Limit</p><p>Return Failed only</p><p>TruncateColumn</p><p>Force</p><p>Default Copy Syntax</p><p>Syntax-</p><p>Copy into &lt;table_name&gt;</p><p>From ExternalStage</p><p>Files = (‘File_name_1’,’File_name_2&#39;)</p><p>FILE FORMAT = &lt;file format name&gt;</p><p><strong>Validation Mode -</strong></p><p>Validate data files instead of loading them</p><p>To check wheater if any error or data is corrupted or not</p><p>Syntax -</p><p>Copy into &lt;table_name&gt;</p><p>From ExternalStage</p><p>Files = (‘File_name_1’,’File_name_2&#39;)</p><p>FILE FORMAT = &lt;file format name&gt;</p><p>VALIDATION_MODE = RETURN_n_ROWS | RETURN_ERROR</p><p>Lets create a Database and Table name in Snowflake for Data Validation</p><p>CREATE OR REPLACE DATABASE COPY_DB;</p><p>CREATE OR REPLACE TABLE COPY_DB.PUBLIC.ORDERS (</p><p>ORDER_ID VARCHAR(30),</p><p>AMOUNT VARCHAR(30),</p><p>PROFIT INT,</p><p>QUANTITY INT,</p><p>CATEGORY VARCHAR(30),</p><p>SUBCATEGORY VARCHAR(30));</p><p>// Prepare stage object</p><p>CREATE OR REPLACE STAGE COPY_DB.PUBLIC.aws_stage_copy</p><p>url=’s3://snowflakebucket-copyoption/size/’;</p><p>LIST @COPY_DB.PUBLIC.aws_stage_copy;</p><p>Before Loading, check the data by running the validation script</p><p>COPY INTO COPY_DB.PUBLIC.ORDERS</p><p>FROM @aws_stage_copy</p><p>file_format= (type = csv field_delimiter=’,’ skip_header=1)</p><p>pattern=’.*Order.*’</p><p>VALIDATION_MODE = RETURN_ERRORS</p><p>Output -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*Mnw5sAZoKrQIBGDFTn-bNg.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>Another which will return ’N’ rows when there are no error in data validation. N = 5</p><p>COPY INTO COPY_DB.PUBLIC.ORDERS</p><p>FROM @aws_stage_copy</p><p>file_format= (type = csv field_delimiter=’,’ skip_header=1)</p><p>pattern=’.*Order.*’</p><p>VALIDATION_MODE = RETURN_5_ROWS</p><p>Output -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nXsp2XD1oUrX7iqbQxsLKA.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>What happens when there are bad records??</p><p>Let’s create another stage object</p><p>// Prepare stage object</p><p>CREATE OR REPLACE STAGE COPY_DB.PUBLIC.aws_stage_copy</p><p>url=’s3://snowflakebucket-copyoption/returnfailed/’;</p><p>Run the validation script -</p><p>COPY INTO COPY_DB.PUBLIC.ORDERS</p><p>FROM @aws_stage_copy</p><p>file_format= (type = csv field_delimiter=’,’ skip_header=1)</p><p>pattern=’.*Order.*’</p><p>VALIDATION_MODE = RETURN_ERRORS</p><p>Output -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLwjV6i7f_6DnbefEww15A.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>Working with Error -</p><p>Now we can see our validation get failed. What will be the next step? How we should remove those error so our data would be clean?</p><p>There will be lots of question arises after getting an Error. In Snowflake, approach is little bit different. Lets find out -</p><p>Method 1</p><p>First we will store the Error buy running few scripts -</p><p>// Storing rejected /failed results in a table</p><p>CREATE OR REPLACE TABLE rejected AS</p><p>select rejected_record from table(result_scan(last_query_id())); — Run this scripts it will give you error records from last run query</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*LD6EmJNAlSUi26GjxUkFeQ.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>INSERT INTO rejected</p><p>select rejected_record from table(result_scan(last_query_id()));</p><p>SELECT * FROM rejected;</p><p>Method 2</p><p>Suppose we have to load data into target table and also check/save error records. We can achive this by below comand</p><p>COPY INTO COPY_DB.PUBLIC.ORDERS</p><p>FROM @aws_stage_copy</p><p>file_format= (type = csv field_delimiter=’,’ skip_header=1)</p><p>pattern=’.*Order.*’</p><p>ON_ERROR=CONTINUE</p><p>This will load data, only those records which don’t have any error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1GpZMdwJ7S18QpRQSHcefA.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>Check the Status column. It clearly says there are some bad records in the file due to which its loaded only Partial Data.</p><p>select * from table(validate(orders, job_id =&gt; ‘_last’));</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x--iU3OEoIFoJZXnzxm0ow.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>Error Details and File name can be found in using the select statement.</p><p>Key points to be noted -</p><p>select * from table(validate(table_name, job_id =&gt; Query_id));</p><p>If we place ‘_last’ this will give error records from last executed query. If you want for some other query, you will need Query ID of that execution command.</p><p>Then create a table and insert records just like Method 1</p><p>How to understand what error message is saying -</p><p>Run the select command over the table to check what kind of data is loaded and do the sum with rejected table records.</p><p>If you notice the error message is nothing but the records which are populated in single column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*1ZZdofqtzMKgWY8N0l2YWQ.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p>Now, we will split the records into multiple and replace those with new records(modified records).</p><p>CREATE OR REPLACE TABLE rejected_values as</p><p>SELECT</p><p>SPLIT_PART(rejected_record,’,’,1) as ORDER_ID,</p><p>SPLIT_PART(rejected_record,’,’,2) as AMOUNT,</p><p>SPLIT_PART(rejected_record,’,’,3) as PROFIT,</p><p>SPLIT_PART(rejected_record,’,’,4) as QUATNTITY,</p><p>SPLIT_PART(rejected_record,’,’,5) as CATEGORY,</p><p>SPLIT_PART(rejected_record,’,’,6) as SUBCATEGORY</p><p>FROM rejected;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VjfKpxHHggFNxdzx_Xv6dw.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p><strong>Size Limit -</strong></p><p>This will help to load data into target table by specifying threshold file size. After the threshold reached data load will get stop. Size in bytes.</p><p>Note — The file size limit of for all file which will be loaded.</p><p>Syntax -</p><p>Copy into &lt;table_name&gt;</p><p>From ExternalStage</p><p>Files = (‘File_name_1’,’File_name_2&#39;)</p><p>FILE FORMAT = &lt;file format name&gt;</p><p>Size_limit = num;</p><p><strong>Return Failed Only -</strong></p><p>It is used when you want to specify those files which are failed to return while loading the data.</p><p>Syntax -</p><p>Copy into &lt;table_name&gt;</p><p>From ExternalStage</p><p>Files = (‘File_name_1’,’File_name_2&#39;)</p><p>FILE FORMAT = &lt;file format name&gt;</p><p>ON_Error = continue</p><p>RETURN_FAILED_ONLY = TRUE; //Default is FALSE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBWkEkxm29nLKUrsnaDX5Q.png" /><figcaption>Copy option in Snowflake DW</figcaption></figure><p><strong>TRUNCATECOLUMS -</strong></p><p>Suppose you created a table with column of 10 character length. But while loading the data there is one record which have char length greater then 10 i.e 12. Using this option those extra char will be truncated to avoid error while copying data into the Target table.</p><p>In simple terms, extra char will be truncated.</p><p>Syntax -</p><p>Copy into &lt;table_name&gt;</p><p>From ExternalStage</p><p>Files = (‘File_name_1’,’File_name_2&#39;)</p><p>FILE FORMAT = &lt;file format name&gt;</p><p>TRUNCATECOLUMNS = True;</p><p>//False will produce error while loading data into Target.</p><p><strong>Force -</strong></p><p>Specifies to load files weather they are already loaded or not changed since they have loaded.</p><p>Leads to duplication of data</p><p>Syntax -</p><p>Copy into &lt;table_name&gt;</p><p>From ExternalStage</p><p>Files = (‘File_name_1’,’File_name_2&#39;)</p><p>FILE FORMAT = &lt;file format name&gt;</p><p>FORCE = TRUE; //Default is FALSE</p><p>Some of my other blog -</p><p><a href="https://sarveshpandey23.medium.com/loading-data-in-snowflake-41be081fe812">Loading Data in Snowflake. So, on the previous blog we have… | by Sarvesh Pandey | Jun, 2022 | Medium</a></p><p><a href="https://sarveshpandey23.medium.com/database-in-snowflake-dc9fd94f4703">Database in Snowflake. If I ask this question… | by Sarvesh Pandey | Jun, 2022 | Medium</a></p><p><a href="https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e">Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium | Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17209855cad9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loading Data in Snowflake]]></title>
            <link>https://sarveshpandey23.medium.com/loading-data-in-snowflake-41be081fe812?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/41be081fe812</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Fri, 24 Jun 2022 11:41:23 GMT</pubDate>
            <atom:updated>2022-06-24T11:41:23.860Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stpEzU7TFIpGu1MzAeUsUQ.jpeg" /><figcaption>Loading Data in Snowflake.</figcaption></figure><p>So, on the previous blog we have learned and understand <a href="https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e">Snowflake Architecture</a> and How to create <a href="https://sarveshpandey23.medium.com/database-in-snowflake-dc9fd94f4703">Database, Table</a></p><p>As the table were empty there are multiple ways to insert data into a table.</p><p>But if we have to load data which is already existing in different source or in some file format or in same server, for these scenario Snowflake have different which is quite help. Lets look into this,</p><p>Snowflake provide two ways or method to load data into tables -</p><p><strong>Bulk Loading and Continuous Loading</strong></p><p>Bulk Load — Loading the whole data at one time</p><ol><li>Most Frequent Load</li><li>Uses Warehouse</li><li>Loading from Stages</li><li>Copy command</li><li>Transformation possible</li></ol><p>Continuous Load -</p><ol><li>Designed to load small volume of Data</li><li>Automatically gets loaded once they are added to stages</li><li>Latest data always available for analysis</li><li>Snow-pipe (Serverless feature)</li></ol><p>We would need stages to performing Loading in Snowflake -</p><p>Stages are the database objects which have target database or table location where data can be loaded</p><p><strong>Types of Stages -</strong></p><p>External Stages</p><ul><li>External cloud provider service are used</li><li>S3 from AWS</li><li>Azure blob storage from Azure</li><li>GCP</li><li>Database object created in schema</li><li>Create stage command</li></ul><p>Note — Addition cost map apply if region/platform differs</p><p>Internal Stages</p><ul><li>Local storage maintained by SNOWFLAKE</li></ul><p><strong>Steps to create Stages on snowflake</strong></p><p>Follow the command below -</p><p>// CREATE A NEW DATABASE</p><p>create or replace database MANAGE_DB;</p><p>// CREATE SCHEMA FOR EXTERNAL STAGES</p><p>CREATE OR REPLACE SCHEMA EXTERNAL_STAGE;</p><p>// CREATING EXTERNAL STAGES QUERY</p><p>CREATE OR REPLACE STAGE MANAGE_DB.EXTERNAL_STAGE.AWS_STAGE — FULLY QUALIFIED STAGE NAME</p><p>url=’s3://bucketsnowflakes3&#39;</p><p>credentials=(aws_key_id=’ABCD_DUMMY_ID’ aws_secret_key=’1234abcd_key’);</p><p>// DESCRIPTION OF STAGE</p><p>DESC STAGE MANAGE_DB.EXTERNAL_STAGE.AWS_STAGE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*sQsTljsCW5P4t1SDTcMA-Q.png" /><figcaption>Loading Data in Snowflake.</figcaption></figure><p>//ALTER STAGE</p><p>ALTER STAGE AWS_STAGE</p><p>SET credentials=(aws_key_id=’ABCD_DUMMY_ID’ aws_secret_key=’your_key’);</p><p>// PUBLICALLY ACCESS STAGING AREA</p><p>CREATE OR REPLACE STAGE MANAGE_DB.EXTERNAL_STAGE.AWS_STAGE</p><p>url=’s3://bucketsnowflakes3&#39;;</p><p>// LIST STAGE</p><p>LIST @AWS_STAGE — @ IS USED AS A PREFIX FOR EXTERNAL STAGING OBJECTS</p><p><em>Note — To load data into any any source or Target, 1st we have to create a table in it. Its a very important step in Loading data between same or different services</em></p><p>// Creating ORDERS table</p><p>CREATE OR REPLACE TABLE OUR_FIRST_DB.PUBLIC.ORDERS (</p><p>ORDER_ID VARCHAR(30),</p><p>AMOUNT INT,</p><p>PROFIT INT,</p><p>QUANTITY INT,</p><p>CATEGORY VARCHAR(30),</p><p>SUBCATEGORY VARCHAR(30));</p><p>SELECT * FROM OUR_FIRST_DB.PUBLIC.ORDERS — EMPTY TABLE</p><p><strong>Performing Bulk load of data from Staging Table on Snowflake Table</strong></p><p>// COPY COMMAND NEED FULLY QUALIFIED NAME</p><p>// First copy command</p><p>COPY INTO OUR_FIRST_DB.PUBLIC.ORDERS — TARGET</p><p>FROM @MANAGE_DB.EXTERNAL_STAGE.AWS_STAGE — SOURCE</p><p>file_format = (type = csv field_delimiter=’,’ skip_header=1);</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*l2T5Erhh_PIrWKNA2asXxA.png" /><figcaption>Loading Data in Snowflake.</figcaption></figure><p>— This will throw error as there are multiple files present in the AWS stage and some file are not able to map with Orders table</p><p>LIST @MANAGE_DB.EXTERNAL_STAGE.AWS_STAGE</p><p>// COPY COMMAND WITH SELECTIVE FILES</p><p>COPY INTO OUR_FIRST_DB.PUBLIC.ORDERS — TARGET</p><p>FROM @MANAGE_DB.EXTERNAL_STAGE.AWS_STAGE — SOURCE</p><p>file_format = (type = csv field_delimiter=’,’ skip_header=1)</p><p>files = (‘OrderDetails.csv’)</p><p>SELECT * FROM OUR_FIRST_DB.PUBLIC.ORDERS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OdsC-kLeLvFK4NYyv5dsiA.png" /><figcaption>Loading Data in Snowflake.</figcaption></figure><p>— What if we again load the data? Try it yourself and let me know in the comments. It will be great practice for you!!</p><p>— truncate table OUR_FIRST_DB.PUBLIC.ORDERS</p><p>// COPY COMMAND WITH PATTERN</p><p>COPY INTO OUR_FIRST_DB.PUBLIC.ORDERS</p><p>FROM @MANAGE_DB.external_stage.aws_stage</p><p>file_format= (type = csv field_delimiter=’,’ skip_header=1)</p><p>pattern=’.*Order.*’;</p><p>In the next Blog we will see “How to handle Error in Bulk Load”.</p><p>Some of my other blog -</p><ol><li><a href="https://sarveshpandey23.medium.com/database-in-snowflake-dc9fd94f4703">Database in Snowflake. If I ask this question… | by Sarvesh Pandey | Jun, 2022 | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e">Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/parameter-passing-moving-multiple-file-from-blog-storage-to-azure-sql-db-37999caa9bd3">Parameter Passing — Move multiple Files from Blog Storage to Azure SQL DB | by Sarvesh Pandey | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/database-backup-location-is-azure-74a6c5dcfd6c">Database Backup Location is AZURE! | by Sarvesh Pandey | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/starting-with-machine-learning-with-python-df7d446369bc">Starting Machine Learning with Python! | by Sarvesh Pandey | May, 2022 | Medium</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41be081fe812" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database in Snowflake]]></title>
            <link>https://sarveshpandey23.medium.com/database-in-snowflake-dc9fd94f4703?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc9fd94f4703</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Sun, 19 Jun 2022 10:20:18 GMT</pubDate>
            <atom:updated>2022-06-19T10:20:18.935Z</atom:updated>
            <content:encoded><![CDATA[<h3>Database in Snowflake. If I ask this question…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stpEzU7TFIpGu1MzAeUsUQ.jpeg" /><figcaption>Snowflake Database</figcaption></figure><p>If I ask this question “What are Database?” the answer would be -</p><p><em>Databases are logical structures used to organize and store data for future processing, retrieval, or evaluation. In the context of computers, these structures are nearly always managed by an application called a database management system or DBMS. The DBMS manages dedicated files on the computer’s disk and presents a logical interface for users and applications.</em></p><p>From &lt;<a href="https://www.prisma.io/dataguide/intro/what-are-databases#what-are-databases">https://www.prisma.io/dataguide/intro/what-are-databases#what-are-databases</a>&gt;</p><p>Now, If I ask the same question with a twist, “What are Snowflake Database?” answer would be different -</p><p><em>Snowflake provides a system-defined, read-only shared database named SNOWFLAKE that contains metatdata, as well as historical usage data, about the objects in your organization and accounts.</em></p><p><em>When an account is provisioned, Snowflake automatically imports the SNOWFLAKE database into the account from a share named ACCOUNT_USAGE. The database is an example of Snowflake utilizing </em><a href="https://docs.snowflake.com/en/user-guide-data-share.html"><em>Secure Data Sharing</em></a><em> to provide object metadata and other usage metrics for your organization and accounts.</em></p><p>From &lt;<a href="https://docs.snowflake.com/en/sql-reference/snowflake-db.html">https://docs.snowflake.com/en/sql-reference/snowflake-db.html</a>&gt;</p><p>In simple terms, Snowflake databases are a more modern type of database architecture. Their rise in popularity reflects the way companies use data today and what platforms they prefer to access their information.</p><p><em>Unlike its predecessor, the star schema, snowflake schemas allow greater flexibility when designing and managing databases. They’re also easier to maintain and update than traditional relational databases.</em></p><p><strong>Lets get quick overview of Database on Snowflake Portal -</strong></p><p>Login into the snowflake portal and click on Database Tab, this will show you all the list of databases currently created/present in snowflake -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ftFiheW4_ivNLkiw2DM0w.png" /><figcaption>Snowflake Database</figcaption></figure><p>Below table show List of Database and all the other details.</p><p>Now, If you click any of the databases you will get more information regarding the tables, views, schema, etc.</p><p>Click on SNOWFLAKE_SAMPLE_DATA Database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4FY9kU7fLFKyOE7CrtzIA.png" /><figcaption>Snowflake Database</figcaption></figure><p>If you click on the column name, it will sort in Ascending or Descending Order or there will be a Drop-Down arrow option will display to select and choose the required action.</p><p>Lets, click on the Rows and Sort it in Descending Order.</p><p>Click on STORES_SALES, snowflake will drill-down and give more information like column name, datatype, default type of column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*vy1CC3UltAM3195wAB-4SA.png" /><figcaption>Snowflake Database</figcaption></figure><p>Likewise for Views, Schema, Stages and other options.</p><p>To go back to the previous page, click on this, it will take back you to previous page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*IXgmgrN1-4wknrzeYo8dNA.png" /><figcaption>Snowflake Database</figcaption></figure><p>Going back to Table and schema level, when you click Table multiple option will display like create, create like, clone, upload. Each action has its own meaning</p><ol><li>Create a Table</li><li>Create Like</li><li>Clone an existing table</li><li>Load Data</li><li>Drop</li><li>Transferring Ownership</li></ol><p>We will see this action step by step in later.</p><p>Staring with</p><p>Creating Database in Snowflake</p><p>Go to the Database page and above the list of database name there will be an option called “Create” with + sign. Click on it.</p><p>A window will pop up and write the database name you wish to be named.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Ocj__ZAu8Pt9LlbPDOK2Q.png" /><figcaption>Snowflake Database</figcaption></figure><p>Click on Finish</p><p>Now, Database is created but if you click on your database it will be blank with no Tables and Views. Note — If you click on Schema, two schema will be created with name INFORMATION_SCHEMA and PUBLIC</p><p>Next question comes to our mind how will you create table and add columns into the database. There will an option present “Create” click on it and follow the steps below -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*sEcMrMTnztPr9iUkk_zI2w.png" /><figcaption>Snowflake Database</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*zhoNqbeKpL3aVSLQgfX9xg.png" /><figcaption>Snowflake Database</figcaption></figure><p>Now, Table STUDENTS will be created with the following column</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*AgwgLAKQhRx_s1ZugKPeyA.png" /><figcaption>Snowflake Database</figcaption></figure><p>To check the data present in the Table -&gt;Go to Worksheet and run the below command</p><p>select * from “SARVESHDB”.”PUBLIC”.”STUDENTS”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52k0Nisy7JIh1Gq4R4rIGQ.png" /><figcaption>Snowflake Database</figcaption></figure><p>Next question comes to our mind is “How to load data? Is there any special method present in Snowflake or it use the Traditional methos?”</p><p>Well the answer is both Yes and No which depends on the scenario. If we look as a beginner perspective we will simply have to use “Insert” command to insert the records into the table but if we look from DBA perspective we need to LOAD the data.</p><p>There is lot of difference between INSERT and LOAD.</p><p>Insert -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*X5FuWjNwjpcvkrF2H1CgJg.png" /><figcaption>Snowflake Database</figcaption></figure><p>INSERT[OVERWRITE]INTO<em>&lt;target_table&gt;</em>[(<em>&lt;target_col_name&gt;</em>[,…])]{VALUES({<em>&lt;value&gt;</em>|DEFAULT|NULL}[,…])[,(…)]|<em>&lt;query&gt;</em>}</p><p>From &lt;<a href="https://docs.snowflake.com/en/sql-reference/sql/insert.html">https://docs.snowflake.com/en/sql-reference/sql/insert.html</a>&gt;</p><p>Series of Snowflake blog coming up soon. Stay connected!</p><p>Some of my other blog -</p><ol><li><a href="https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e">Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/restore-database-in-azure-sql-database-using-sqlpackage-exe-9fb2aa30966d">Restore backup file in Azure SQL Database using SQLPackage.exe | by Sarvesh Pandey | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/database-backup-location-is-azure-74a6c5dcfd6c">Database Backup Location is AZURE! | by Sarvesh Pandey | Medium</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc9fd94f4703" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snowflake Architecture and Warehouse]]></title>
            <link>https://sarveshpandey23.medium.com/snowflake-architecture-and-warehouse-b8d283a1510e?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8d283a1510e</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[warehouse]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Tue, 14 Jun 2022 21:01:32 GMT</pubDate>
            <atom:updated>2022-06-14T21:01:32.268Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stpEzU7TFIpGu1MzAeUsUQ.jpeg" /><figcaption><em>Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium</em></figcaption></figure><p>As every Engineer or person who works on data had heard Snowflake for the first time, thought it would we a schema to relate Fact and Dimension table and I thought the same as well XD.</p><p>Snowflake is nothing but a cloud hosted data warehouse which is specifically built for Cloud services like Azure, AWS and GCP. In simple words, a data warehouse build on these three cloud services data center.</p><p>This blog will help you to understand the Snowflake warehouse Architecture and how to create a Virtual Warehouse in Snowflake. Series on blog will come soon on different topic on Snowflake cloud service.</p><h3><strong>Architecture</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Oqigg5JdA_rA5CpEaHmGng.png" /><figcaption><em>Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium</em></figcaption></figure><p>Snowflake is divided into three parts Storage, Query Processing and Cloud Services</p><p><strong>Storage </strong>— Hybrid Columnar Storage, saved in blobs</p><p><strong>Query Processing </strong>— Performs MPP (Virtual Warehoused)</p><p><strong>Cloud Services </strong>— Managing Infra, Access control, Security, Monitor, Optimizer, etc</p><p><strong>Virtual Warehouse </strong>—</p><p>Virtual Warehouse is present in Query Processing Layer which handles the query performance by using Massively Parallel Process Concept</p><p>It is not data warehouse. It’s a cluster or a group of compute resources which query to process quickly as per requirement.</p><p>Virtual warehouse in snowflake comes with different sizes -</p><p>Smallest is XS and Largest is 4XL</p><p>XS — 1</p><p>S — 2</p><p>M — 4</p><p>L — 8</p><p>XL -16</p><p>2XL -32</p><p>3XL — 64</p><p>4XL — 128</p><p><strong>Steps to create Virtual Warehouse in Snowflake:</strong></p><p>Step 1: Connect to your snowflake account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*AfrBGHEEk3x_vnQXQ4Vyig.png" /><figcaption><em>Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium</em></figcaption></figure><p>Step 2: Click on the warehouse icon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0gbBgByFpq6NQ8tBi4k4PQ.png" /><figcaption><em>Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium</em></figcaption></figure><p>Step 3: Click in Create to Create Virtual Warehouse. Pop windows will come on screen, fill the requires information and Click on Finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*U3FsFL14NV2HFkbcBsy5VQ.png" /><figcaption><em>Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium</em></figcaption></figure><p>Step 4: You can Configure your virtual warehouse by clicking on Configure button next to create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*4YwP9ReZxVqd4kFCx5QOLg.png" /><figcaption><em>Snowflake Architecture and Warehouse | by Sarvesh Pandey | Medium</em></figcaption></figure><p>Step 5: Next to Configure, there is Suspend and Resume bottom to manually Stop and Start the cluster. Drop button is to delete the Warehouse.</p><h3><strong>Scaling Virtual Warehouse</strong></h3><p><strong>Scaling Out</strong></p><p>Multi-clustering — Also known as Horizontal Scale up</p><p>Same number of cores added together to improve the query queuing of users or Multiple user can run query at same time without letting query into Queue</p><p><strong>Scaling Up</strong></p><p>Vertical Scale up. Scaling up the warehouse size to improve query performance</p><p>While creating Warehouse in Snowflake there is an option of proving Minimum and Maximum cluster.</p><p>Snowflake will auto-scale based on the warehouse scaling policy. If the number is the same in both min and max, the warehouse will always resume with that number of clusters</p><p>Also, there is another field of Scaling Policy with two options “Standard” (default) and “Economy”.</p><p><strong>Standard </strong>-</p><p>Focus on Not letting Query to get into a queue by scaling out the warehouse (Horizontal Scaling)</p><p>Immediately scales up cluster size when there is query is in queue or system detects other query can be executed.</p><p><strong>Economy </strong>-</p><p>Focus on using the cluster size completely then scale out the warehouse (Horizontal Scaling) only if system detect enough load on cluster to increase the cluster size</p><p>These are some basic information on Snowflake Cloud Warehouse and how user can create a warehouse.</p><p>Series of Snowflake blog coming up soon. Stay connected!</p><p>.</p><p>.</p><p>.</p><p>Some of my other blog -</p><ol><li><a href="https://sarveshpandey23.medium.com/restore-database-in-azure-sql-database-using-sqlpackage-exe-9fb2aa30966d">Restore backup file in Azure SQL Database using SQLPackage.exe | by Sarvesh Pandey | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/database-backup-location-is-azure-74a6c5dcfd6c">Database Backup Location is AZURE! | by Sarvesh Pandey | Medium</a></li><li><a href="https://sarveshpandey23.medium.com/migrate-database-from-sql-server-to-azure-sql-vm-using-azure-data-studio-preview-39f75fd85a26">Migrate Database from SQL Server to Azure SQL VM using Azure Data Studio (Preview) | by Sarvesh Pandey | Medium</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8d283a1510e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Starting Machine Learning with Python!]]></title>
            <link>https://sarveshpandey23.medium.com/starting-with-machine-learning-with-python-df7d446369bc?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/df7d446369bc</guid>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[music]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Sun, 01 May 2022 12:25:35 GMT</pubDate>
            <atom:updated>2022-05-01T12:35:24.572Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning is not a new word in this world but its highly popular. So, why is it popular so much? One answer is it ML algorithm can make predictions and take decision on its own.</p><p>This article, will give you a basic idea of how you can write a ML code of your own using Python and its modules.</p><p>We are going to use sample music dataset and do some predications. Big Shoutout to Programming with Mosh. Go check it out his video on YouTube.</p><p>Pre-requisite&#39;s</p><ol><li><a href="https://bit.ly/3muqqta">music dataset</a> Click to download</li><li>Jupyter notebook (Anaconda)</li><li>Basic Python knowledge</li></ol><p>Basic rule to follow while doing ML analysis-</p><ol><li>Import the Data</li><li>Check null data and Clean the Data</li><li>Try to convert into numeric data (good for ML)</li><li>Split the dataset into Training and Test</li><li>Create a Model</li><li>Make Predictions</li><li>Evaluate and Improve</li></ol><p>Lets Begin our ML Journey!</p><p>Open your Anaconda application and Launch Jupyter Notebook</p><p>Launch a new Python notebook</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZJA8cGXZfr6SHm900ymcQ.png" /><figcaption>Starting with Machine Learning with Python!</figcaption></figure><p>Import some python ML modules</p><p>import pandas as pd</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*GXseH7mUzsg2zFUko3q39w.png" /><figcaption>Starting with Machine Learning with Python!</figcaption></figure><p>Use pandas to read the musical csv files in Jupyter Notebook</p><p>df = pd.read_csv(“musical file path”)</p><p>#Check null data is present</p><p>df.isnull().sum() #0 indicate there is no null values in dataset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*9dgL1TwQRxFQNuvr2qqITg.png" /><figcaption>Starting with Machine Learning with Python!</figcaption></figure><p>#Split the dataset for testing and training</p><p>x = df.drop(columns =[“genre”])<br>y = df[“genre”]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*V4yRqWPSXuks6v1K8M81lA.png" /><figcaption>Starting with Machine Learning with Python!</figcaption></figure><p>from sklearn.model_selection import train_test_split</p><p>x_train,x_test,y_train,y_test = train_test_split(x,y,test_size = 0.2)</p><p>#Okay, so we are good till here. We have check the null values and split the dataset for training and testing.</p><p>#Note- Larger the training dataset more accurate will be the predictions</p><p>#Choose a Machine Learning Algorithm</p><p>from sklearn.tree import DecisionTreeClassifier</p><p>model = DecisionTreeClassifier()</p><p>model.fit(x_train,y_train)</p><p>#Now, to predict the values follow the below command.</p><p>predictions = model.predict([[21,1]])</p><p>#[21,1] represents Age of 21 with gender Male as 1 = Male and 0 = Female</p><p>predictions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*mNKqD7wW_JR-R6H_gZu6IQ.png" /><figcaption>Starting with Machine Learning with Python!</figcaption></figure><p>#To check the accuracy of your ML Algo -</p><p>from sklearn.metrics import accuracy_score</p><p>#calculating accuracy<br>#score = accuracy_score(y_test,predictions)<br>#score</p><p>#If score is = 1, model is 100% accurate, 0.75 means accuracy is 75% and so on.</p><p>#Actual script for reference</p><p>import pandas as pd<br>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.model_selection import train_test_split<br>from sklearn.metrics import accuracy_score<br>df = pd.read_csv(“\\Users\\MYPCDELLPC\\Desktop\\Python\\Project\\music\\music.csv”)<br>x= df.drop(columns = [“genre”])<br>y = df[“genre”]</p><p>x_train,x_test,y_train,y_test = train_test_split(x,y,test_size = 0.2)</p><p>model = DecisionTreeClassifier()<br>model.fit(x_train,y_tra#calculating accuracy<br>#score = accuracy_score(y_test,predictions)<br>#scorei<br>predictions = model.predict(x_test)<br>predictions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*m7aiyekrCsf6IuQriC3ntg.png" /><figcaption>Starting with Machine Learning with Python!</figcaption></figure><p>#Note — replace x_test value with [Age,Gender]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df7d446369bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB]]></title>
            <link>https://sarveshpandey23.medium.com/parameter-passing-moving-multiple-file-from-blog-storage-to-azure-sql-db-37999caa9bd3?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/37999caa9bd3</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[parameterization]]></category>
            <category><![CDATA[azure-data-factory]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Sat, 30 Oct 2021 18:24:55 GMT</pubDate>
            <atom:updated>2021-10-30T18:46:09.154Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Parameter Passing — Move multiple Files from Blog Storage to Azure SQL DB</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*hPhxa7yqBeXUQ0C53B5VVg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p><strong>Introduction</strong> -</p><p>Passing parameters to ADF is quite important as it provides the flexibility required to create dynamic pipelines. In simple terms, Parameter makes your ADF pipeline reusable.</p><p>To reference a parameter, one will have to provide the fully qualified name of the parameter. It is worth noting that parameter names are case sensitive.</p><p>A parameter could be a user input, which means that the parameter is passed from the pipeline layer or could be an input coming from an activity within the pipeline.</p><p><strong>Prerequisite –</strong></p><p>· Sample Source Flat File</p><p>· Create Azure Data Factory</p><p>· Linked Service for Azure Blob Storage and Azure SQL DB</p><p><strong>Steps to Create Static Pipeline in Azure Data Factory</strong></p><p>Step 1 — Sample Flat File in Azure Blob Storage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*vRDjUYElu8H2xJvOWvtyTg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 2 — Create Schema of above file in Azure SQL DB</p><p><em>CREATE TABLE Cars (</em></p><p><em>Make nvarchar(100),</em></p><p><em>Model nvarchar(200),</em></p><p><em>Type nvarchar(100),</em></p><p><em>Origin nvarchar(100),</em></p><p><em>DriveTrain nvarchar(100),</em></p><p><em>Length decimal(18,0)</em></p><p><em>)</em></p><p><em>CREATE TABLE Planes (</em></p><p><em>ICAO nvarchar(200),</em></p><p><em>IATA nvarchar(200),</em></p><p><em>MAKER nvarchar(200),</em></p><p><em>DESCRIPTION nvarchar(200)</em></p><p><em>)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*f92pP2Ct3UICaoC_s3SjVQ.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 3 — Linked Service in Azure Data Factory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*cLqs2s-lxM3ffRXOgeIS6g.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*F6wPmQbnXKBLNSwu_Ee8Pg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 4 — Click on Author Tab and Create a New Pipeline “Static Pipeline”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*F6wPmQbnXKBLNSwu_Ee8Pg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 5 — Create two data Sets for Azure Blob Storage and Azure SQL DB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*vHDeHtuEvyeU5GKHCjEZ-A.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*0bdn2EPpNsvcbd1tx7RTZA.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 6 — Drag <strong>Copy Data </strong>from Move and Transform Activities and connect Sink and Source.</p><p>Hit Debug to execute Pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Ev0k5ZKH6hZ-dhbYehMrhg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p><em>Note — Debug will execute the pipeline without saving it in Azure Data Factory. Make sure to Hit Publish if you want to use any pipeline regularly.</em></p><p>Our Pipeline executed successfully. Now we can modify this pipeline to dynamic using parameter and make it reusable for N number of files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*9etiUDjbbnQN5ona3hRf7w.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p><strong>Steps to Create Static Pipeline in Azure Data Factory (Parameters on Datasets)</strong></p><p><em>Note — This Pipeline will need parameters (file and table name) before pipeline executions</em></p><p>Step — 1 Clone the above Pipeline and rename it to <strong>Dynamic Pipeline</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*cBzVnRlgGO7tNbrcxrXUKg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*8NcLplkB2-qPaDZbDBC1wg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step — 2 Go to the Dataset and Click on Parameters</p><p>AzureSQLDB_Dest</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*6wz1ciy_93H6VHPb8aAjFQ.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>SourceBlob</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*SLa9N94k6xv2agdjgsjyRA.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 3 — Go to Connection tab on each of the Datasets and pass the parameters in the File path</p><p>Click on <strong>Add dynamic content</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*a9jewIDZqqOz8jTXEkGOJg.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Select the parameter of Azure Blob Storage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*ocfJ2lC8hp5vwSvAfk7JhA.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*7BHUMKZ08ghofHGFd3pchQ.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Repeat the above steps for Azure SQL Database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*JWvEqTVf16nsczJJb6fbEQ.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 4 — Go to the pipeline -&gt; under Dataset Properties ADF automatically picks the parameters</p><p>Pass the table which you want to move to Azure SQL DB.</p><p>Let’s move Plane table from Azure Blob Storage to Azure SQL DB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*gH05xweUAyz-Od0X6k13Aw.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*05kz0Samd1b0HsmfgtDjcA.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 5 — Hit the Debug button to execute the pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*z9MmBhWcQzWyz99YtIW3Ww.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>You can see, we have used the Static script, added some parameters, and made it dynamic and reusable <strong>EFFORTLESSLY!!</strong></p><p><strong>Steps to Create Static Pipeline in Azure Data Factory (Parameters on Pipeline)</strong></p><p><em>Note — This Pipeline will ask parameters (file and table name) at the time of executions</em></p><p>Step 1 — Click outside the Copy data Activity and go to Parameters -&gt; Add two parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*CfsZY8X5_jXGF9GHDdkBKw.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 2 — Go to Source -&gt; click on <strong>Add Dynamic Content </strong>under Dataset Properties -&gt; Select parameters name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*T6h7WKJCs-06s3cTdwGp1w.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*4HfowPRAsYGzGbyj9W2C7A.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Step 3 — Click on Debug to execute the pipeline</p><p>Before that, lets see the row count of cars and plane table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*6EYij1P5ysHtnevxwhg5-Q.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><p>Pass the parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*LLoUxxhqDz-05Pba5lI1ew.png" /><figcaption>Parameter Passing — Moving multiple File from Blog Storage to Azure SQL DB</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37999caa9bd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Server Schema Comparison using Azure Data Studio]]></title>
            <link>https://sarveshpandey23.medium.com/sql-server-schema-comparison-using-azure-data-studio-7ad51551a9ba?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ad51551a9ba</guid>
            <category><![CDATA[studio]]></category>
            <category><![CDATA[azure-data-studio]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[azure-sql-database]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Sat, 28 Aug 2021 19:27:05 GMT</pubDate>
            <atom:updated>2021-08-28T19:30:04.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*M3pfEevSw_Kc7S89gUdiYg.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Introduction:</p><p>Schema Comparison is an important step in UAT and Production. This is useful method to compare your UAT and Production Database and Schema without running complex SQL Queries.</p><p>This article will help you to understand Azure Data Studio which a Database Management Tool by Microsoft is to manage On-premises SQL Server, SQL Server on Azure VM, Azure SQL Database and Managed Instance. Schema Comparison is feature provided in this toll which helps user to compare database present in On-premises or in Azure Cloud.</p><p>Azure Data Studio Compare Table, View, Stored Procedure, Functions, Logins, Users</p><p>Prerequisites:</p><p>1. <a href="https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15">Download and install Azure Data Studio — Azure Data Studio | Microsoft Docs</a></p><p>2. User must have “db­_owner” role to apply those changes.</p><p>3. Schema between the database should be similar/same.</p><p>4. SQL Server Authentication is recommended.</p><p>Step to Compare Schema:</p><p>Step 1: <a href="https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15">Download and install Azure Data Studio — Azure Data Studio | Microsoft Docs</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*ybkFRN0KJMEhAIiYnCHUKA.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 2: Open the Azure Data Studio Tool -&gt; Click on the Feature Icon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*DuEhSx7WurxGusVibZgBgg.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 3: Search <strong>SQL Server Schema Compare </strong>and Click on Install</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*DuEhSx7WurxGusVibZgBgg.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 4: Connect to Azure SQL Server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*KD6o6qiEH2vAtqhPnBSH5Q.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 5: Right on Source database (DB1) and click on <strong>Compare Schema</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*jD5SSlA4q6Vm2p4ZUYzonA.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 6: Choose target Server but click on ellipsis</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*NhndvGBTjoe-pjFPQPERSA.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 7: Connect to Target Server and Provide Credentials -&gt; Click on “OK”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*_6ZpPC8zLlEjknprOuAzFQ.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Note — You can compare a Dacpac with database or Dacpac with Dacpac</p><p>Step 8: Click on Compare Button to Compare Schema of database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*TyQigkbg5xv90muZOOpOPg.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 9: You can see the comparison Table of two database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*5fVxHLZ7U_inAxrkfp0j6Q.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 10: Action column display which action its going to get performed on Destination</p><p>Delete — Respected object going to get deleted</p><p>Add — Respected object going to get added</p><p>Change — Respected changes to be made on object</p><p>Step 11: Click on Table with “Change” Action, you can see schema comparison between two tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*SDOO-vgZKtl_HcbkW_NJAw.png" /><figcaption>SQL Server Schema Comparison using Azure Data Studio</figcaption></figure><p>Step 12: Click on “Apply” to reflected these changes on Destination Database.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ad51551a9ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database Backup Location is AZURE!]]></title>
            <link>https://sarveshpandey23.medium.com/database-backup-location-is-azure-74a6c5dcfd6c?source=rss-59fb5955aac6------2</link>
            <guid isPermaLink="false">https://medium.com/p/74a6c5dcfd6c</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[database-backup]]></category>
            <category><![CDATA[mssql]]></category>
            <dc:creator><![CDATA[Sarvesh Pandey]]></dc:creator>
            <pubDate>Sun, 18 Jul 2021 16:55:47 GMT</pubDate>
            <atom:updated>2021-07-18T16:55:47.253Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>SQL Server backups are an essential part of every good disaster recovery strategy. But setting up such backups to run effortlessly, is the goal. In this article, we will show you how schedule backups automatically setting up SQL Server backups on a schedule to Azure Storage Account.</p><p>This method is suitable for <strong>SQL Server</strong> and <strong>Azure SQL Managed Instance</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*USEUTx8aoZ_lOf_ogoOHmA.jpeg" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><p><strong>Prerequisites</strong></p><p>· Azure Storage Account</p><p>· <strong>sysadmin</strong> role on the login role</p><p>· Sample <a href="https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver15&amp;tabs=ssms">AdventureWorks</a> Database</p><p>· SQL Server Any Edition and SSMS</p><p><strong>Steps to setup the environment –</strong></p><p>Step 1 — <a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal">Create an Azure Storage Account and a Container</a></p><p>Step 2 — Connect your SQL Server with SSMS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*T9BO_iX4GVbHnMHb8VfM-w.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><p>Step 3 — Expand and Right Click Management and open Management Plan Wizard</p><p>Step 4 — Fill the details and select the Scheduling Time. I schedule it to run this Job every 1 hour, Daily.</p><p>Step 5 — Select the Database Backup Type</p><p>Step 6 — Select the required Database name and Backup to <strong>URL </strong>option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*L0XCbT213B1XtAxErsaCtA.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><p>Step 7 — Go back to Server, Expand Security -&gt; Right Click on Credentials and select New Credential</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*b9LfvEI6vPJIFb5FB4c1AQ.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><p>Step 8 — Write Azure Storage Account Name in Identity Box. Paste Storage Account Access Keys in Password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*kJcqXkmeMghVKqjpwlTViw.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*nBua7MKgewf35aQ3DctPlA.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><p>Step 9 — Select the SQL Credentials which we have created in previous Step. Write Storage Container name in the next field. Verify the URL Prefix and backup extension type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*cWvuiEme25FO7n4kfUWXmw.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><p>Step 10 — Click on Next and Finish the Management Wizard.</p><p>Step 11 — Expand Maintenance Plan and you can see a backup job is created. Right Click on the Job and click on execute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*txIG4vhnaxZIfPWPwDbfoQ.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><p>Step 12- After the job ran successfully, you can monitor your job by clicking on <strong>View History</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*-S6Qn4r974ImvrFsWM7vwg.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*eU0bdZQm5IllUZR3aVKfjw.png" /><figcaption>Database Backup Location is AZURE!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74a6c5dcfd6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>