Can anyone tell me what is wrong with this stored procedure?
CREATE PROCEDURE [dbo].[AddGroupPermission]
@.Perm varchar(16)
AS
ALTER TABLE tblUserGroups ADD @.Perm VARCHAR(1) NULL
GO
When I click on Check Syntax, I get 'Error 170 - Line 4: Incorrect syntax near @.Perm'
I have checked the syntax for the ALTER command, and it looks correct to me...
This is my first day at using SQL Server in anger, so any help appreciated :)You must use dynamic sql for that, check out :
http://www.sqlteam.com/item.asp?ItemID=4599
The following will work
CREATE PROCEDURE [dbo].[AddGroupPermission]
@.Perm varchar(16)
AS
exec ('ALTER TABLE tblUserGroups ADD ' + @.Perm + 'VARCHAR(1) NULL')
GO|||Oh wow! Thanks for that - I didn't even know you could do that directly in SQL server - I'm used to doing it in ASP pages, of course, but this DB is new to me :)
I'm off to check your link now - thanks very much for taking the time to post.
Mark.sql
Showing posts with label alter. Show all posts
Showing posts with label alter. Show all posts
Sunday, March 25, 2012
Thursday, February 16, 2012
<Alter Login sa - SQL 2005 - Login Failed>
Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005. After
doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
that login failed.
How i can i login back?
Thanks
I figured out the problem. When i changed the login to xxxsa, SQL Server
changed the login to 'xxxsa' (with the quotes). When i used the login with
the quotes, it worked.
"Houston Lucifer" wrote:
> Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005. After
> doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
> that login failed.
> How i can i login back?
> Thanks
>
doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
that login failed.
How i can i login back?
Thanks
I figured out the problem. When i changed the login to xxxsa, SQL Server
changed the login to 'xxxsa' (with the quotes). When i used the login with
the quotes, it worked.
"Houston Lucifer" wrote:
> Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005. After
> doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
> that login failed.
> How i can i login back?
> Thanks
>
<Alter Login sa - SQL 2005 - Login Failed>
Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005. A
fter
doing this, i cannot login using the sa or xxxsa user id. It keeps telling m
e
that login failed.
How i can i login back?
ThanksI figured out the problem. When i changed the login to xxxsa, SQL Server
changed the login to 'xxxsa' (with the quotes). When i used the login with
the quotes, it worked.
"Houston Lucifer" wrote:
> Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005.
After
> doing this, i cannot login using the sa or xxxsa user id. It keeps telling
me
> that login failed.
> How i can i login back?
> Thanks
>
fter
doing this, i cannot login using the sa or xxxsa user id. It keeps telling m
e
that login failed.
How i can i login back?
ThanksI figured out the problem. When i changed the login to xxxsa, SQL Server
changed the login to 'xxxsa' (with the quotes). When i used the login with
the quotes, it worked.
"Houston Lucifer" wrote:
> Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005.
After
> doing this, i cannot login using the sa or xxxsa user id. It keeps telling
me
> that login failed.
> How i can i login back?
> Thanks
>
<Alter Login sa - SQL 2005 - Login Failed>
Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005. After
doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
that login failed.
How i can i login back?
ThanksI figured out the problem. When i changed the login to xxxsa, SQL Server
changed the login to 'xxxsa' (with the quotes). When i used the login with
the quotes, it worked.
"Houston Lucifer" wrote:
> Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005. After
> doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
> that login failed.
> How i can i login back?
> Thanks
>
doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
that login failed.
How i can i login back?
ThanksI figured out the problem. When i changed the login to xxxsa, SQL Server
changed the login to 'xxxsa' (with the quotes). When i used the login with
the quotes, it worked.
"Houston Lucifer" wrote:
> Hi all, i issued the alter login sa name = [xxxsa] on SQL Server 2005. After
> doing this, i cannot login using the sa or xxxsa user id. It keeps telling me
> that login failed.
> How i can i login back?
> Thanks
>
Subscribe to:
Posts (Atom)