I have Sybase version 10.0.1.3960 and 'inherited' very large database. I am trying to grant SELECT
privileges on all tables to a single user.
The problem is there are a lot of tables, 681 tables to be exact!
Too many tables to write the query manually, so I generated the sql progamatically. The trouble is that the programatically generated is too long. Sybase has a VARCHAR
limit of 32767 (2^15-1) and the query is longer than that. I tried defining a LONG VARCHAR
but I keep getting an error.
I'm at my rope's end, how can I make this work?
DECLARE @login VARCHAR(255)
DECLARE @payload VARCHAR(32765) -- <-- too few characters, too many tables
SELECT @login = 'myUserLogin'
SELECT @payload = Result.Payload FROM (
SELECT LIST(tbl.ApplicableAsset, ';\n') AS 'Payload'
From (
SELECT 'GRANT SELECT ON ' + name + ' TO ' + @login +'' AS 'ApplicableAsset'
FROM sysobjects
WHERE type='U'
) AS tbl
) AS Result
EXECUTE ( @payload )