Reputation: 1142
I need to know if the used INTO
SQL Server and equivalent ROWNUM
in SQL Server
SELECT
SERIE, CORRELATIVO
INTO
vSerie, vCorrelativo
FROM
SIG.SAF_SERIES_DOCUMENTOS_DET
WHERE
COMPANIA = pCompania
AND MONTO = pMonto
AND ESTADO = 'P'
AND ROWNUM = 1;
Upvotes: 0
Views: 55
Reputation: 12318
This should do it, although you're missing an order by:
SELECT top 1
@vSerit = SERIE,
@vCorrelativo = CORRELATIVO
FROM SIG.SAF_SERIES_DOCUMENTOS_DET
WHERE COMPANIA = @pCompania
AND MONTO = @pMonto
AND ESTADO = 'P'
If you need something else than the first row, You can also do a row_number() window function as a column into your select and use that to limit the data or use offset / fetch if you're in SQL Server 2012 or use top twice with asc / desc order by
Upvotes: 1