Question : Syntax error in Stored Procedure

I get the following error "incorrect syntax error near '@FSE', Expection ID, or Quoted_ID." on the attached code.  I am struggling with SQL and server 2008 but am determined to move from MS Access.  Please help.
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

Answer : Syntax error in Stored Procedure

Use this in place of your create user line, it will build the string with the value of @FSE in it and then execute it.
1:
2:
3:
4:
5:
6:
DECLARE @strSQL NVARCHAR(1000);

set @strSQL = 'CREATE USER ' + @FSE + ' FOR LOGIN FSE;';

EXEC sys.sp_executesql @strSQL
  
Random Solutions  
 
programming4us programming4us