在存储过程中我收到错误 [英] In stored procedure i am getting error

查看:71
本文介绍了在存储过程中我收到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在存储过程中我将参数传递为nvarchar,为了测试目的我添加打印,在此下面我得到SP中的错误



- Exec SPDelFile N 'รู้จักกับDreamweaver.docx',N 'รู้จักกับW',N 'รู้จักกับDreamweaver.docx',N 'รู้จักกับ\รู้จักกับ\รู้จักกับDreamweaver.docx',N'รู้จักกับw\ รู้จักกับ\รู้จักกับ 'N 'รู้จักกับ\รู้จักกับ\รู้จักกับDreamweaver.docx',N 'รู้จักกับw\รู้จักกับ\รู้จักกับ\รู้จักกับDreamweaver.docx',N' รู้จัก กับw'



执行SP后,我得到打印结果



Hi In stored procedure i pass parameter as nvarchar,for testing purpose i add Print,below this i get error in SP

-- Exec SPDelFile N'รู้จักกับ Dreamweaver.docx', N'รู้จักกับw',N'รู้จักกับ Dreamweaver.docx',N'รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx',N'รู้จักกับw\รู้จักกับ\รู้จักกับ',N'รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx',N'รู้จักกับw\รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx',N'รู้จักกับw'

After execut SP,below i get Print result

Delete from [รู้จักกับw] where [File Name] = รู้จักกับ Dreamweaver.docx and [File Path] = รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'Dreamweaver'.







这是我的SP并在同一个窗口用于测试i执行使用Exec




This is my SP and in same window for testing i execute using Exec

USE [Employee]
GO
 
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
ALTER PROCEDURE [dbo].[SPDelFile]
 	 @TblName nvarchar(256),
	 @FileName1 nvarchar(256),
	 @FilePath1 nvarchar(256),
	 @TblNameIndx nvarchar(256)
AS
 	   Declare @DelTblPos nvarchar(max); 
		SET @DelTblPos = 'Delete from ['+ @TblName +'] where [File Name] = '+ @FileName1 +' and [File Path] = ' + @FilePath1 ; 
        Print @DelTblPos;
		EXEC (@DelTblPos);  
		
		Declare @DelIndexing nvarchar(max); 
		SET @DelIndexing = 'Delete from [FTIndexing] where [Filename] = '+ @FileName1 +' and [Filepath] = ' + @FilePath1 + ' and [Database] = ' + @TblNameIndx ; 
	    Print @DelIndexing;
	    EXEC (@DelIndexing);  
			
	RETURN

		-- Exec SPDelFile N'รู้จักกับ Dreamweaver.docx', N'รู้จักกับw',N'รู้จักกับ Dreamweaver.docx',N'รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx',N'รู้จักกับw\รู้จักกับ\รู้จักกับ',N'รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx',N'รู้จักกับw\รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx',N'รู้จักกับw'  - > this is problem

-- Exec SPDelFile N'รู้จักกับ กับ.docx', N'รู้จักกับw',N'รู้จักกับ กับ.docx',N'รู้จักกับ\รู้จักกับ\รู้จักกับ กับ.docx',N'รู้จักกับw\รู้จักกับ\รู้จักกับ',N'รู้จักกับ\รู้จักกับ\รู้จักกับ กับ.docx',N'รู้จักกับw\รู้จักกับ\รู้จักกับ\รู้จักกับ กับ.docx',N'รู้จักกับw'  - > this is problem  - > this is Working





所有参数都声明为nvarchar。



请回复我如何解决这个问题。

上面的值是泰语,如果全部是英文,那么没问题



注意:如果这样的文件名รู้จักกับDreamweaver.docx --->问题

如果像这样Dreamweaver.docx - >没问题



问候

Aravind



我有什么尝试过:



注意:如果这样的文件名รู้จักกับDreamweaver.docx --->问题

如果像这样Dreamweaver.docx - >没问题



All parameters declare as nvarchar.

Pls reply me how to solve this.
The above values are Thai language,if all are in English then no problem

Note:if file name like this รู้จักกับ Dreamweaver.docx --- > Problem
if like this Dreamweaver.docx--> no Problem

Regards
Aravind

What I have tried:

Note:if file name like this รู้จักกับ Dreamweaver.docx --- > Problem
if like this Dreamweaver.docx--> no Problem

推荐答案

行情,我的朋友,你需要报价。

试试:

Quotes, my friend, you need quotes.
Try:
DELETE FROM [รู้จักกับw] WHERE [File Name] = N'รู้จักกับ Dreamweaver.docx' AND [File Path] = N'รู้จักกับ\รู้จักกับ\รู้จักกับ Dreamweaver.docx'

由于您使用的是泰语字符,N前缀向SQL表明它是一个Unicode字符串。

Since you are using Thai characters, the "N" prefix indicates to SQL that it's a Unicode string.


这篇关于在存储过程中我收到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆