1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: xxx -- Create date: 8/24/2010 -- Description: Creates new user for login FSE -- ============================================= CREATE PROCEDURE usp_CreateFSE -- Add the parameters for the stored procedure here @FSE nvarchar(33) = 0 AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here CREATE USER @FSE FOR LOGIN FSE -- TODO: grant access to stored procedure to update tblUserInfo END GO
1: 2: 3: 4: 5: 6:
DECLARE @strSQL NVARCHAR(1000); set @strSQL = 'CREATE USER ' + @FSE + ' FOR LOGIN FSE;'; EXEC sys.sp_executesql @strSQL