Results 1 to 4 of 4

Thread: procedure

  1. #1
    Join Date
    Feb 2010
    Posts
    9

    Smile Unanswered: procedure

    can we create a table using procedure?
    And then insert some data into the table and finally shows that table.
    is this possible?

    like

    create procedure test5 as
    create table empl ( id int,names varchar(20),manid varchar(20),sal int)
    insert into empl values (1,'a','1',15)
    insert into empl values (2,'b','1',20)
    insert into empl values (3,'c','2',11)
    insert into empl values (4,'d','2',12)
    insert into empl values (5,'e','3',8)
    select * from empl

    exec test5



    please give me a link on procedure

    thanks
    Last edited by shantanu4u; 04-21-10 at 03:47. Reason: mistake

  2. #2
    Join Date
    Dec 2008
    Posts
    135
    how can u create a table in the stored procedure
    if u execute another time it will show u alter table is exist as error message
    u can insert the data through stored procedure..........
    actually what is ur requirement?

  3. #3
    Join Date
    Feb 2010
    Posts
    9
    please tell me how to create a job which runs the procedure in sql sever 2005 management studio

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    CREATE PROCEDURE dbo.your_proc99 (
       @some_param char(1)
    )
    AS
      BEGIN
        CREATE TABLE #imma_temp_table (
           some_field char(1)
        )
    
        INSERT INTO #imma_temp_table (some_field) VALUES (@some_param)
    
        SELECT some_field
        FROM   #imma_temp_table
      END
    GO
    George
    Home | Blog

Posting Permissions

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