Results 1 to 4 of 4

Thread: [RESOLVED] Translation required: PLSQL to T-SQL

  1. #1

    Thread Starter
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Resolved [RESOLVED] Translation required: PLSQL to T-SQL

    Hello Folks,
    I have the following PL/SQL code that needs to be translated to T-SQL for SQL Server.
    sql Code:
    1. DECLARE
    2.   x INTEGER := 100;
    3.   y INTEGER := 10;
    4. BEGIN
    5. WHILE x != 110 LOOP
    6.      INSERT INTO tab_for_nulls(rollno, marks) VALUES(x, y);
    7.      x:=x+1;
    8. END LOOP;
    9. END;

    Thanks!
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Translation required: PLSQL to T-SQL

    Try this:

    Code:
    DECLARE @x INTEGER
    DECLARE @y INTEGER
    SELECT @x= 100, @y = 10
    BEGIN
    	WHILE x <> 110 
    	     INSERT INTO tab_for_nulls(rollno, marks) VALUES(@x, @y)
    	     Set @x = @x+1
    	END 
    END;
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: Translation required: PLSQL to T-SQL

    Quote Originally Posted by GaryMazzone View Post
    Try this:

    Code:
    DECLARE @x INTEGER
    DECLARE @y INTEGER
    SELECT @x= 100, @y = 10
    BEGIN
    	WHILE x <> 110 
    	     INSERT INTO tab_for_nulls(rollno, marks) VALUES(@x, @y)
    	     Set @x = @x+1
    	END 
    END;
    Thanks for jogging my memory.

    Here's your code with syntax issues fixed.

    SQL Code:
    1. DECLARE @x INTEGER
    2. DECLARE @y INTEGER
    3. SELECT @x= 100, @y = 10
    4. BEGIN
    5.     WHILE @x <> 110
    6.     BEGIN
    7.          INSERT INTO
    8.          [TAB_FOR_NULLS]([ROLLNO],[MARKS])
    9.            VALUES(@x, @y)
    10.          Set @x = @x+1
    11.     END
    12. END
    13. GO


    I heard that you can write C# code in SQL 2008. Have you given that a whirl?
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Translation required: PLSQL to T-SQL

    Quote Originally Posted by abhijit View Post
    I heard that you can write C# code in SQL 2008. Have you given that a whirl?
    There is a link in the "SQL Server" section of our Database Development FAQs/Tutorials to a fairly simple tutorial on it (for VB.Net, but it should be virtually identical).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width