Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with. 
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         kabon 
                                        Starting Member 
                                         
                                        
                                        48 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2012-06-18 : 04:30:37
                                            
  | 
                                             
                                            
                                            | Excuse me,I want to ask how to display like this using leading zero:10000011000002100000310000041000005100000610000071000008100000910000101000011I have the code but can't show the answer like that, this is my code:declare @startrange int, @ID intset @startrange = 0while @startrange <= 10BEGINset @ID = '1' + RIGHT('00000000'+CONVERT(varchar,@startrange),10)PRINT @IDset @startrange = @startrange + 1ENDGOCan you help me?And last, I want to know how to create temporary table and how to use it?thanks... | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     khtan 
                                    In (Som, Ni, Yak) 
                                     
                                    
                                    17689 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-18 : 04:38:33
                                          
  | 
                                         
                                        
                                          [code]declare	@startrange	intselect	@startrange = 1; with rcte as(	select	ID = @startrange	union all	select	ID = ID + 1	from	rcte	where	ID	<= 10)select	100000000 + IDfrom	rcte[/code] KH[spoiler]Time is always against us[/spoiler]  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     kabon 
                                    Starting Member 
                                     
                                    
                                    48 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-18 : 23:43:21
                                          
  | 
                                         
                                        
                                          | If I change where ID <= 110, why this code error?how about using temporary table and how to use it to cleared this problem?help me,please....  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     khtan 
                                    In (Som, Ni, Yak) 
                                     
                                    
                                    17689 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-19 : 00:00:46
                                          
  | 
                                         
                                        
                                          it is a recursive CTE. The default value for MAXRECURSION is 100Specify the maxrecursion value or 0 for no limit.FROM    rcteOPTION (MAXRECURSION 1000);  KH[spoiler]Time is always against us[/spoiler]  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     kabon 
                                    Starting Member 
                                     
                                    
                                    48 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-19 : 02:35:19
                                          
  | 
                                         
                                        
                                          | ehm, it's error.where I must place that code?Msg 156, Level 15, State 1, Line 16Incorrect syntax near the keyword 'OPTION'.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     khtan 
                                    In (Som, Ni, Yak) 
                                     
                                    
                                    17689 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-19 : 02:42:44
                                          
  | 
                                         
                                        
                                          quote: Originally posted by kabon ehm, it's error.where I must place that code?
  I have already shown that in my post on 06/19/2012 :  00:00:46 KH[spoiler]Time is always against us[/spoiler]  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     kabon 
                                    Starting Member 
                                     
                                    
                                    48 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-19 : 23:14:22
                                          
  | 
                                         
                                        
                                          | I had replace     select	ID = ID + 1 	          from	rcte	          where	ID	<= 10to      select	ID = ID + 1	FROM    rcte        OPTION (MAXRECURSION 1000);	where	ID	<= 10but it always appear error that incorrect near OPTION  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     khtan 
                                    In (Som, Ni, Yak) 
                                     
                                    
                                    17689 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-19 : 23:19:04
                                          
  | 
                                         
                                        
                                          [code]declare	@startrange	intselect	@startrange = 1; with rcte as(	select	ID = @startrange	union all	select	ID = ID + 1	from	rcte	where	ID	<= 110)select	100000000 + IDfrom	rcteOPTION (MAXRECURSION 1000);[/code] KH[spoiler]Time is always against us[/spoiler]  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |   
     
     
            
              
	     |  
		
			
     
          
		 |