October 28, 2011 at 2:58 am
I used dynamic SQL to make a stored procedure to create login :
USE [db901_DEV]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_SSSA_login]
@input_login VARCHAR(50), @input_pass VARCHAR(50)
AS
BEGIN
DECLARE @cmd nvarchar(2000)
SET @cmd = 'CREATE LOGIN ' + @input_login +' WITH PASSWORD = ' + QUOTENAME(@input_pass,'''')
+ ', DEFAULT_DATABASE= ' + QUOTENAME('db901_DEV','')
+ ', DEFAULT_LANGUAGE= ' + QUOTENAME('us_english','')
+ ', CHECK_EXPIRATION=OFF '
+ ', CHECK_POLICY=OFF '
Exec sp_executesql @cmd
END
If I execute it :
sp_SSSA_login 'tw.test_901', '7A6b5c'
It failed.
If I execute it :
sp_SSSA_login 'tw_test_901', '7A6b5c'
It works.
Could you tell me why ?
October 28, 2011 at 3:08 am
Replace the CREATE LOGIN statement with the below statement
SET @cmd = 'CREATE LOGIN [' + @input_login +'] WITH PASSWORD = ' + QUOTENAME(@input_pass,'''')
October 28, 2011 at 3:39 am
That's great !
It works. Thanks a lot.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply