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)
 creating stored procedure

Author  Topic 

vinay789
Starting Member

40 Posts

Posted - 2009-04-22 : 06:39:48
Hi to everyone i am a newbie to ms sql i am creating a stored procedure to retrive data for the logged user give me some examples.
Thanx

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-22 : 06:46:31
[code]CREATE PROCEDURE dbo.spMyFirstProcedure
(
@UserName SYSNAME = NULL
)
AS

SET NOCOUNT ON

SET @UserName = COALESCE(@UserName, SUSER_SNAME())

SELECT *
FROM MyTable
WHERE MyUser = @UserName
GO[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -