T-SQL小例


   
   
   
   
  1. declare @x int,@y int,@z int 
  2. select @x=1,@y=2,@z=3--t-sql select , set  
  3. if @x>@y  
  4. print 'x>y' 
  5. else if @y>@z  
  6. print 'y>z' 
  7. else print 'z>y' 
  8.  
  9. declare @x int ,@y int ,@c int 
  10. select @x=1,@y =1  
  11. while @x<3  
  12. begin 
  13. print @x  
  14. while @y<3  
  15. begin 
  16. select @c = 100*@x+@y  
  17. print @c  
  18. select @y=@y+1  
  19. end 
  20. select @x=@x+1  
  21. select @y=1  
  22. end 
  23.  
  24. -- waitfor  
  25. waitfor delay '00:00:30'-- 30  
  26. select * from student  
  27. waitfor time '18:18:18'-- 18:18:18    
  28. select * from student