Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/05/2013, 13:11
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: Numero de Semana Con Numero de Mes

Código SQL:
Ver original
  1. CREATE TABLE #temp
  2. (
  3. semana INT,
  4. mes INT
  5. )
  6.  
  7. DECLARE @inicio datetime
  8. DECLARE @x INT
  9. DECLARE @YEAR INT
  10. SET @x=1
  11. SET @inicio='01/01/2013'
  12. SET @YEAR=DATEPART(YYYY,@inicio)
  13. while @x=1
  14. BEGIN
  15. INSERT INTO #temp
  16.  SELECT datepart(wk,@inicio) semana ,DATEPART(mm,@inicio) mes
  17.  SET @inicio=DATEADD(DD,7,@inicio)
  18.  IF DATEPART(yyyy,@inicio)<>@YEAR
  19.     SET @x=0
  20. END
  21.  
  22. SELECT * FROM #temp
  23. DELETE FROM #temp

saludos!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me