Msg 102, Level 15, State 1, Line 1 Falsche syntax in der Nähe 'D:'
Ich versuchen, eine gespeicherte Prozedur aufrufen:
CREATE PROCEDURE [dbo].[uspImportDepartment2]
@filePath nvarchar(255),
@formatPath varchar(255),
@countInsert Int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @sqlstmt nvarchar(255)
DECLARE @results table (result xml)
--Build the Dynamic SQL Statement to get the data from the xml file
SET @sqlstmt= N'SELECT * FROM OPENROWSET ( BULK ' + @filePath + ', FORMATFILE=''' + @formatPath + ''', FIRSTROW=1, MAXERRORS=0)AS xmlData'
-- Insert the results of the dynamic SQL Statement into the temporary table variable.
INSERT INTO @results EXEC (@sqlstmt)
select @countInsert = count(*) from @results
--DECLARE @xmlDoc XML
--SELECT @xmlDoc = result FROM @results
END
GO
Und Ausführung code:
DECLARE @count1 int
EXEC [dbo].[uspImportDepartment2] @filePath = 'D:\test_1.txt',
@formatPath = 'D:\test_1_c.fmt', @countInsert = @count1 OUTPUT
SELECT @count1 as AAAA
Aber es wirft einen Fehler:
Msg 102, Level 15, State 1, Line 1
Falsche syntax in der Nähe 'D:'.
Kann jemand mir sagen, was das problem ist?
Dank!
Die \ (backslash) ist ein escape-Zeichen. Machen Sie Ihren Weg mit 2 von Ihnen \\
InformationsquelleAutor Tien Nguyen | 2014-09-16
Du musst angemeldet sein, um einen Kommentar abzugeben.
Anführungszeichen fehlen , schreiben als:
Erfahren Sie mehr über die syntax von
OPENROWSET
Funktion von hier:http://msdn.microsoft.com/en-IN/library/ms190312(v=sql.100).aspx
QUOTENAME(@path, '''')
statt, es behandelt auch eingebettete Zitate, wenn überhaupt. Wie ist nun der code ist eine SQL-Injection-Vektor.InformationsquelleAutor Deepshikha
Ich hatte das gleiche Problem. Ich denke, dass müssen Sie ein Leerzeichen vor "ALS"
InformationsquelleAutor alexvam