我正在尝试通过变量来自动化和创建用户。
declare @userid CHAR(8), @username CHAR(100), @role char(13), @password
char(8)
SELECT @userid = "sas99887"
SELECT @username = "TEST"
SELECT @role = (@userid + "_role")
SELECT @password = "testpass"
create role @role
但是最后一行的@role语法无效 这是在Sybase ASE服务器上
答案 0 :(得分:0)
请使用以下代码:
declare @userid CHAR(8), @username CHAR(100), @role char(13), @password
char(8), @cmd varchar(200)
SELECT @userid = "sas99887"
SELECT @username = "TEST"
SELECT @role = (@userid + "_role")
SELECT @password = "testpass"
select @cmd = "create role " || @role
exec (@cmd)