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 |
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2007-03-28 : 06:45:35
|
| I am getting the following error if there are no records in the table. The 'project_priority' field in an intCannot insert the value NULL into column 'project_priority', table 'nsvrc.dbo.Projects'; column does not allow nulls. INSERT fails.The statement has been terminated.ALTER PROCEDURE dbo.InsertProject ( @txtTopic AS VARCHAR(100), @userid AS int, @maxID as int OUTPUT )ASSET NOCOUNT ON INSERT INTO Projects (project_priority, project_Desc, userID, lastModified) SELECT MAX(project_priority)+1, @txtTopic,@userid, GETDATE() FROM Projects SET @maxID = Scope_Identity() SET NOCOUNT OFF RETURN |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-28 : 06:46:49
|
quote: Originally posted by helixpoint I am getting the following error if there are no records in the table. The 'project_priority' field in an intCannot insert the value NULL into column 'project_priority', table 'nsvrc.dbo.Projects'; column does not allow nulls. INSERT fails.The statement has been terminated.ALTER PROCEDURE dbo.InsertProject ( @txtTopic AS VARCHAR(100), @userid AS int, @maxID as int OUTPUT )ASSET NOCOUNT ON INSERT INTO Projects (project_priority, project_Desc, userID, lastModified) SELECT IsNull(MAX(project_priority),0)+1, @txtTopic,@userid, GETDATE() FROM Projects SET @maxID = Scope_Identity() SET NOCOUNT OFF RETURN
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-28 : 06:49:19
|
| [code]ALTER PROCEDURE dbo.InsertProject ( @TxtTopic VARCHAR(100), @UserID INT, @MaxID INT OUTPUT)ASSET NOCOUNT ON SELECT @MaxID = MAX(Project_Priority)FROM ProjectsIF @MaxID IS NULL SET @MaxID = 1INSERT Projects ( Project_Priority, Project_Desc, UserID, LastModified )VALUES ( @MaxID, @TxtTopic, @UserID, CURRENT_TIMESTAMP )SET NOCOUNT OFFSET @MaxID = SCOPE_IDENTITY()[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-03-28 : 07:20:49
|
its trying to tell you that Project_Priority is supposed to be an IDENTITY field [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|
|
|