使用 SSMS 18.0 Preview 6 编写函数脚本会产生以下脚本。
@ViewChild('formRecipe') formRecipe: ngForm;
//or, if using angular8,
// @ViewChild('formRecipe',{static : true}) formRecipe: ngForm;
constructor(private changeDetectorRef: ChangeDetectorRef){}
onCloseMember(){
this.formRecipe.reset();
this.changeDetectorRef.detectChanges();
}
使用 SSMS 2016 编写相同功能的脚本会产生该脚本
/****** Object: UserDefinedFunction [dbo].[sfn_Proper_Case] Script Date: 7/13/2019 9:57:36 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sfn_Proper_Case]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'
CREATE FUNCTION [dbo].[sfn_Proper_Case]
(
@input NVARCHAR(4000)
)
RETURNS NVARCHAR(4000)
AS
BEGIN
SET @input = REPLACE(REPLACE(REPLACE(@input,'' '',''<>''),''><'',''''),''<>'','' '');
DECLARE @output NVARCHAR(512);
DECLARE @current_position INT = 1;
IF DATALENGTH(@input) > 0
BEGIN
SET @output = '''';
END;
WHILE @current_position <= DATALENGTH(@input)
BEGIN
DECLARE @check_character NVARCHAR(1);
DECLARE @previous_character NVARCHAR(1);
DECLARE @output_character NVARCHAR(1);
SELECT @check_character = LOWER(SUBSTRING(@input,@current_position,1));
SELECT @previous_character = SUBSTRING(@input,@current_position
- 1,1);
IF @previous_character NOT LIKE ''[a-z]''
AND @check_character LIKE ''[a-z]''
BEGIN
SELECT @output_character = UPPER(@check_character);
END;
ELSE
BEGIN
SELECT @output_character = @check_character;
END;
SET @output = @output
+ @output_character;
SET @current_position = @current_position
+ 1;
END;
RETURN @output;
END;
'
END
GO
问题-我需要在SSMS 18中更改哪些脚本选项,因此它不会在使用 {生成的输出脚本中添加/****** Object: UserDefinedFunction [dbo].[sfn_Proper_Case] Script Date: 7/13/2019 9:55:43 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[sfn_Proper_Case]
(
@input NVARCHAR(4000)
)
RETURNS NVARCHAR(4000)
AS
BEGIN
SET @input = REPLACE(REPLACE(REPLACE(@input,' ','<>'),'><',''),'<>',' ');
DECLARE @output NVARCHAR(512);
DECLARE @current_position INT = 1;
IF DATALENGTH(@input) > 0
BEGIN
SET @output = '';
END;
WHILE @current_position <= DATALENGTH(@input)
BEGIN
DECLARE @check_character NVARCHAR(1);
DECLARE @previous_character NVARCHAR(1);
DECLARE @output_character NVARCHAR(1);
SELECT @check_character = LOWER(SUBSTRING(@input,@current_position,1));
SELECT @previous_character = SUBSTRING(@input,@current_position
- 1,1);
IF @previous_character NOT LIKE '[a-z]'
AND @check_character LIKE '[a-z]'
BEGIN
SELECT @output_character = UPPER(@check_character);
END;
ELSE
BEGIN
SELECT @output_character = @check_character;
END;
SET @output = @output
+ @output_character;
SET @current_position = @current_position
+ 1;
END;
RETURN @output;
END;
GO
前缀和双引号N'
{1}} 或 ''string literals''
此选项有效,但我不想删除对象 Right Click->Script Function as->CREATE TO
PS:我不记得是否在SSMS 2016的脚本选项下进行了更改以实现此目的,或者它是否是默认设置。谢谢!
答案 0 :(得分:1)
您可以在以下位置更改此行为:
SSMS->工具->选项-> SQL Server对象资源管理器->脚本->对象 脚本选项
对于SSMS 16,属性Include IF NOT EXISTS clause
应设置为False
图片来源:https://social.microsoft.com/Forums/getfile/14300/
对于SSMS 18,属性Check for object existence
应该设置为False