I have an RCCC table with RCCC_ID being an IDENTITY column. The following SQL fails:
with this error message:
[red]Cannot add identity column, using the SELECT INTO statement, to table '#TMP_RCCC', which already has column 'RCCC_ID' that inherits the identity property.[/red]
I can understand that part, but the query runs if I add a join to the FROM clause:
[blue] LEFT JOIN DIRECTORATE_PROGRAMS DP ON R.DIR_PROGRAM_ID = DP.DIR_PROGRAM_ID[/blue]
Why wouldn't the query fail under that second condition? A SQL-ism of some sort?
Also... This is part of a stored proc to implement a paging scheme (only return rows 51 to 75...) since SQL Server doesn't support LIMIT. What is the cleanest way to implement this functionality? I would pass in the page number and rowsPerPage and want the query to only return the appropriate records.
Code:
SELECT
RCCC_ID,
RCCC_TX,
RCCC_TITLE_TX,
R.DIR_PROGRAM_ID,
R.ACTIVE_CD,
CAST(0 AS int) AS RECORD_COUNT_QY,
IDENTITY(int,1,1) AS SORT_ID
INTO #TMP_RCCCS
FROM RCCC R
WHERE 1 = 2
with this error message:
[red]Cannot add identity column, using the SELECT INTO statement, to table '#TMP_RCCC', which already has column 'RCCC_ID' that inherits the identity property.[/red]
I can understand that part, but the query runs if I add a join to the FROM clause:
[blue] LEFT JOIN DIRECTORATE_PROGRAMS DP ON R.DIR_PROGRAM_ID = DP.DIR_PROGRAM_ID[/blue]
Why wouldn't the query fail under that second condition? A SQL-ism of some sort?
Also... This is part of a stored proc to implement a paging scheme (only return rows 51 to 75...) since SQL Server doesn't support LIMIT. What is the cleanest way to implement this functionality? I would pass in the page number and rowsPerPage and want the query to only return the appropriate records.