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.
| Author |
Topic |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-02-01 : 07:43:14
|
| Hello,I am working with VS 2005 and SQL 2005.I have a table with two columns:LevelId[GUID, uniqueidentifier] and LevelName [nvarchar(100)]I need to check if a certain LevelName exists so I created a procedure: -- Begin of procedure code ALTER PROCEDURE [dbo].[by27_Levels_LevelExists] -- Define the procedure parameters @LevelName NVARCHAR(100) AS -- Allows @@ROWCOUNT and the return of number of records when ExecuteNonQuery is used SET NOCOUNT OFF; -- Declare and define LevelId DECLARE @LevelId UNIQUEIDENTIFIER; SELECT @LevelId = LevelId FROM dbo.by27_Levels WHERE LevelName = @LevelName -- Check if LevelId is Not Null IF @LevelId IS NULL BEGIN ??? END ELSE BEGIN ??? END -- Run procedure definition code GOWhat type of feedback should I return?Basically sometimes I need to return some information resulting of my SQL procedure and not records.What should I do so I can read it in my C# code?Thanks,Miguel |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2007-02-01 : 13:13:40
|
quote: Originally posted by Peso See this topichttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=78414Peter LarssonHelsingborg, Sweden
The question here is different.For example, what should be the best way to check if a record with a certain LevelName exists?I am using SELECT ...... but should I Return 0 or 1... or should I check the returned records on my C# code?Thanks,Miguel |
 |
|
|
|
|
|