Parsing technique in sql server

Discussion in 'SQL Server' started by venkatesanj@hcl.in, Mar 4, 2008.

  1. venkatesanj@hcl.in

    venkatesanj@hcl.in New Member

    Joined:
    Oct 19, 2007
    Messages:
    24
    Likes Received:
    1
    Trophy Points:
    0

    Introduction



    This article deals with parsing techniques involved in executing the sql server query. Nowadays, stored procedures forms a strong back ground in accessing the database. Why is it so???? how it's related to my query parsing technique

    Background



    If we think about the query execution there are various steps involved in executing the query such as,
    1. Lexical phase - Code break up will happen at this stage. All my code breaks up as individual tokens.
      Let us consider
      Code:
       int a;  
      The code gets broken like "int" as a separate token and "a" as a seperate token.
    2. Syntax analysis - Here my code gets checked for its syntax.

      In C program we have a standard rule like, if i want to declare a variable we have to specify the variable and followed by variable name and you can specify the values(initialization) followed by semicolor (;)
      Code:
      int i=0; 
      In sql server the syntax for select statement is,
      Code:
         select colname from tablename where condition on the columns  
    3. Semantic phase - Here the semantics will be checked. For example i am trying to execute a simple piece of code in c#,

      Code:
        Console.Writeline(a.ToString());
        int a;
      In the above code my syntax is correct and i have missed my semantics :nonod: because i am trying to print the variable a with out declaring it and i am declaring the same after printing it.
    4. Intermediate code generation - Its the fourth stage where an intermediate code will be generated by the compiler its like converting the high level code to machine level code.
    5. Code Optimization - My compiler will holds some optimization technique to optimize the code so that we can achieve effective execution of our code.
    6. Optimized code generation - After code optimization a final code will be generated which can be used to retrieve the data. In sql server this optimized code will be stored and used frequently to fetch the data from the database.
    7. Code execution - The optimized code gets executed against the database engine.
    Thus stored procedures and triggers are pre-compiled statements, gets executed and an optimized code will be ready to hit the database at any time.

    Please provide me your valuable feedback regarding this article.

    Regards,
    Venkatesan Prabu . J
     
    Last edited: Mar 12, 2008
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  3. subashini

    subashini New Member

    Joined:
    Apr 6, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Very good article.

    I think we can relate this topic with compiler design concepts
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  5. ramyasen

    ramyasen New Member

    Joined:
    Apr 29, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
  6. ramyasen

    ramyasen New Member

    Joined:
    Apr 29, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    how will u give the payment
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Read the rules pinned at the top of the competition forum
     
  8. LenoxFinlay

    LenoxFinlay Banned

    Joined:
    Apr 15, 2009
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    0
    In my environment I have a few tables with thousands of rows that have URLs in particular columns. We are going through some changes in the environment and need to be able to parse out the data (base URL, file name, query parameters) from the specific columns then move the parsed data to another database design. Moving the data is no problem. I plan on using SQL Server 2005 Integration Services and I have a good sense of how to use that tool. By the way, all of the URLs are in varchar fields if that makes any difference. Can you provide any recommendations on how to parse that data?
    Although there are probably a few different ways to approach this task, let's break it apart and see how we can code each one of these scenarios with T-SQL commands in SQL Server 2005. I assume you will be parsing the data from a single column to three new columns in a new database\table design. Since you are familiar with SQL Server 2005 Integration Services, I will not dig into those details and just focus on how to capture the data that you need. So let's take a look at each scenario and give an explanation on the T-SQL coding in SQL Server 2005.
     
  9. technica

    technica New Member

    Joined:
    Dec 15, 2007
    Messages:
    107
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.technicaltalk.net
    Very good article. never new about this before.Thanks for sharing your writing with us all.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice