Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select case in SP

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2008-07-31 : 22:40:28
Can i do the following:
******************************************************************

CREATE PROCEDURE [dbo].[USP_InsertUserModeLogs]
(
@UserID int,
@AccessMode INT
)
AS
SELECT @SQLSelect =
CASE @AccessMode
WHEN 1 THEN 'INSERT INTO TAB_ccsNetUserPrograms_log
(ProgID,
UserID,
AccessMode,
*********************************************************************

Thank you very much for the info.

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2008-08-01 : 00:19:45
Yes, you can use dynamic sql, but this might not be the corect scenerio


SELECT @SQLSelect =
CASE @AccessMode
WHEN 1 THEN 'INSERT INTO TAB_ccsNetUserPrograms_log (ProgID, UserID, AccessMode) values(1,1,1)'
WHEN 2 THEN 'INSERT INTO MySecondTable (ProgID, UserID, AccessMode) values(1,1,2)'
End

exec (@SQLSelect)


Not sure if this is what you wanted.
Go to Top of Page
   

- Advertisement -