Is it possible to convert the following script so that it can be called directly from ADO .NET? I don’t want it to be a stored procedure, and I don’t need TotRows if that makes it easier to convert.
DECLARE @startRow INT ; SET @startrow = 50
;WITH cols
AS
(
SELECT table_name, column_name,
ROW_NUMBER() OVER(ORDER BY table_name, column_name) AS seq,
ROW_NUMBER() OVER(ORDER BY table_name DESC, column_name desc) AS totrows
FROM [INFORMATION_SCHEMA].columns
)
SELECT table_name, column_name, totrows + seq -1 as TotRows
FROM cols
WHERE seq BETWEEN @startRow AND @startRow + 49
ORDER BY seq
The only thing you’d need to do to use inline SQL from C# is to use a parameter instead of a local variable.
Like so.