Settings and activity
2 results found
-
74 votesJames Strath supported this idea ·
An error occurred while saving the comment -
2 votes
An error occurred while saving the comment James Strath commentedCan remove the warning from MIN/MAX also by not initializing when declaring the variable , but I'd rather keep to the original syntax style
no squiggly line in this example
DECLARE @foo INT
SELECT @foo = (MAX([value].[val]))
FROM (VALUES(1),(2),(3))AS[value]([val])SELECT @foo
squiggly line for this preferred syntax:
DECLARE @foo INT = (
SELECT (MAX([value].[val]))
FROM (VALUES(1),(2),(3))AS[value]([val])
)
SELECT @fooAn error occurred while saving the comment James Strath commentedIF EXISTS(SELECT (1) FROM sys.objects [o] WHERE (SCHEMA_NAME([o].[schema_id]) = (N'dbo')) AND [o].[name] = (N'fn_myfunc') AND [o].[type]=(N'FN')) DROP FUNCTION [dbo].[fn_myfunc];
GO
CREATE FUNCTION [dbo].[fn_myfunc] ()
RETURNS NVARCHAR(11)
AS BEGIN
RETURN(N'hello world')
END
GO
;DECLARE @HasWarning nvarchar(11) = (SELECT [dbo].[fn_myfunc]())
;PRINT(@HasWarning)
;DECLARE @NoWarning nvarchar(11) = ([dbo].[fn_myfunc]())
;PRINT(@NoWarning)An error occurred while saving the comment James Strath commentedeg.
DECLARE @foo INT = (
SELECT (MAX([value].[val]))
FROM (VALUES(1),(2),(3))AS[value]([val])
)
SELECT @fooJames Strath shared this idea ·
Absolutely! Such a feature would be most welcome.