Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2012
    Posts
    3

    Unanswered: insert automaticaly many record in sql

    i want insert automatically records for Range that user definded

    for exsample user define :

    from to city
    10000 12000 tehran
    15000 19000 babol

    i shoud inserted 2000 record for tehran (10000,10001,....,12000) and 4000 record for babol (15000,15001,...,19000)

    what i do ?

  2. #2
    Join Date
    Apr 2012
    Posts
    213

  3. #3
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2
    As an aside, those figures will give you 2001 records for Tehran and 4001 records for Babol.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  4. #4
    Join Date
    Jul 2012
    Posts
    3
    hello & Tank u

    i use this query for solve this problem ( create auto matically many record )
    Code:
    CREATE   PROCEDURE [Insert_TEMP]
    	(@F1 	    numeric ,
    	 @F2   	    numeric ,
             @FCity          varchar(20)
    )
    
    AS
    
    SET NOCOUNT ON
    
    while  @F1 <= @F2
    
    begin
     INSERT INTO [Moshtarakin].[dbo].[TBL_TEMP] 
    	 ( [TTF1],
    	   [TTF2],
               [FCity]  
    	) 
     
    VALUES 
    	( @F1,
    	  @F1 + 1,
              @FCity
            )
    
     Set @F1 = @F1 + 1
    
    end
    Is any best way? the speed of this operation is important
    Last edited by mehdi820608; 07-15-12 at 05:59.

Posting Permissions

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