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)
 insert sub-query

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2007-03-14 : 18:34:50
This does not seemto work. I get

Msg 1046, Level 15, State 1, Line 3
Subqueries are not allowed in this context. Only scalar expressions are allowed.


CREATE PROCEDURE dbo.InsertProject

(
@txtTopic AS VARCHAR(100)
)
AS
INSERT INTO Projects
(project_priority, project_Desc)
VALUES ((SELECT MAX(project_priority) FROM Projects) , @txtTopic)
RETURN

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-14 : 18:36:26
CREATE PROCEDURE dbo.InsertProject
(
@txtTopic AS VARCHAR(100)
)
AS

INSERT INTO Projects (project_priority, project_Desc)
SELECT MAX(project_priority), @txtTopic FROM Projects


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2007-03-14 : 19:28:50
Thanks Peter
Go to Top of Page
   

- Advertisement -