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 |
|
fixertool
Starting Member
2 Posts |
Posted - 2011-11-25 : 09:34:41
|
| I cannot solve this syntax problem. Thanks in advance1 USE [someDB]2 GO3 /************/4 SET ANSI_NULLS ON5 GO6 SET QUOTED_IDENTIFIER ON7 GO8 ALTER FUNCTION [dbo].[increment]()9 RETURNS INT10 AS11 BEGIN12 DECLARE @auto INT,13 @result INT14 15 IF (SELECT COUNT(*) FROM sampleTable) > 016 BEGIN17 SELECT @auto = MAX(ord) FROM sampleTable18 @result = @auto + 119 END 20 ELSE21 BEGIN22 @result = 0 23 END;24 25 RETURN @result 26 ENDMsg 102, Level 15, State 1, Procedure increment, Line 11Incorrect syntax near '@result'.Msg 102, Level 15, State 1, Procedure increment, Line 15Incorrect syntax near '@result'. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-25 : 09:43:36
|
| 1 USE [someDB]2 GO3 /************/4 SET ANSI_NULLS ON5 GO6 SET QUOTED_IDENTIFIER ON7 GO8 ALTER FUNCTION [dbo].[increment]()9 RETURNS INT10 AS11 BEGIN12 DECLARE @auto INT,13 @result INT14 15 IF (SELECT COUNT(*) FROM sampleTable) > 016 BEGIN17 SELECT @auto = MAX(ord) FROM sampleTable18 select @result = @auto + 119 END 20 ELSE21 BEGIN22 select @result = 0 23 END;24 25 RETURN @result 26 END==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
fixertool
Starting Member
2 Posts |
Posted - 2011-11-25 : 10:08:06
|
| Thank you! Problem solved. |
 |
|
|
|
|
|