Queries with param
- From: "Johnny Emde" <emde@xxxxxxx>
- Date: Sun, 4 Dec 2005 12:46:38 +0100
Hey Group
Will this be possible to convert into Access (mdb) Query?
CREATE PROCEDURE sp_TeamAdd
@p_TeamName nvarchar(50),
@p_Notes text,
@p_TeamID_out bigint output,
@p_LeaderName nvarchar(10)
AS
-- Teamname can only exists once in the table
IF NOT EXISTS ( SELECT * FROM [tblTeams] WHERE [TeamName] = @p_TeamName)
BEGIN
DECLARE @v_Created datetime
DECLARE @v_Modified datetime
DECLARE @v_LeaderID bigint
SET @v_Created = getdate()
SET @v_Modified = @v_Created
INSERT INTO [tblTeams]
( [TeamName],
[TeamNotes],
[Created],
[Modified]
)
Values
(
@p_TeamName,
@p_Notes,
@v_Created,
@v_Modified
)
SET @p_TeamID_out = SCOPE_IDENTITY()
IF @p_LeaderName IS NOT NULL
SET @v_LeaderID = ( SELECT TOP 1 [UserID] FROM [tblUsers] WHERE
[UserIdent] = @p_LeaderName )
IF @v_LeaderID IS NOT NULL
UPDATE [tblTeams] SET [FK_TeamLeader] = @v_LeaderID WHERE [TeamID] =
@p_TeamID_out
ELSE
RAISERROR ( 'No Leaders was found.', 16, 1 )
END
Kind regards
Johnny Emde Jensen
.
- Follow-Ups:
- Re: Queries with param
- From: Chris2
- Re: Queries with param
- Prev by Date: Re: I need a scredriver, and all I have are hammers...
- Next by Date: How compress and repair mdb?
- Previous by thread: Append & Sub Queries
- Next by thread: Re: Queries with param
- Index(es):
Relevant Pages
|