Ver Mensaje Individual
  #39 (permalink)  
Antiguo 06/09/2012, 15:12
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: Incrementar un campo desde un trigger

me puedes decir este query que te regresa ejecutalo tal cual:


Código SQL:
Ver original
  1. CREATE TABLE #t1 (campo1 VARCHAR(10), campo2 datetime)
  2. INSERT INTO #t1 VALUES ('1',getdate())
  3. INSERT INTO #t1 VALUES ('1',getdate())
  4. INSERT INTO #t1 VALUES ('1',getdate())
  5. INSERT INTO #t1 VALUES ('2',getdate())
  6. INSERT INTO #t1 VALUES ('1',getdate())
  7. INSERT INTO #t1 VALUES ('2',getdate())
  8. INSERT INTO #t1 VALUES ('1',getdate())
  9. INSERT INTO #t1 VALUES ('1',getdate())
  10. INSERT INTO #t1 VALUES ('1',getdate())
  11. INSERT INTO #t1 VALUES ('3',getdate())
  12. INSERT INTO #t1 VALUES ('3',getdate())
  13. INSERT INTO #t1 VALUES ('1',getdate())
  14. INSERT INTO #t1 VALUES ('2',getdate())
  15. GO
  16.  
  17. SELECT ROW_NUMBER() OVER (partition BY campo1 ORDER BY campo1) AS id, campo1,campo2 FROM #t1

te regresa lo que necesitas o no y pon favor por el resultado :)

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