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 |
|
siprem
Starting Member
6 Posts |
Posted - 2008-12-16 : 00:38:35
|
| Hi All, I am getting the following error. Please help me fix this problem.[Error]Msg 214, Level 16, State 2, Procedure sp_executesql, Line 1Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.[Error]The prodecure is below:[Code]CREATE PROCEDURE dbo.sp_ValidateFooterCount(@FileName NVARCHAR(50),@Flag INT OUTPUT)ASBEGINSET nocount ONDECLARE @NumLines VARCHAR(100) DECLARE @XPCmdString VARCHAR(8000)DECLARE @SqlStatement VARCHAR(200)DECLARE @FooterCount VARCHAR(10)SET @XPCmdString = 'find /V /C " " ' + @FileNameCREATE TABLE #XPOutput (XPLineOut varchar(1000))INSERT INTO #XPOutput EXEC master..xp_cmdshell @XPCmdStringDELETE FROM #XPOutput WHERE XPLineOut IS NULLSELECT @NumLines = SUBSTRING (XPLineOut, 12 + len(@FileName) + 2, 1000) FROM #XPOutputSET @SqlStatement ='BULK INSERT #tempfile FROM ''' + @FileName + ''''Create table #tempfile (line varchar(8000))EXEC sp_executesql @SqlStatementDELETE FROM #tempfile WHERE DATALENGTH(line) >6SET @FooterCount= (SELECT line from #tempfile)PRINT @NumLinesPRINT @FooterCountselect @Flag=1--RETURN @FlagEND[Code]The way I am running the procedure is as below:declare @flag intexec [TUAM].[dbo].sp_ValidateFooterCount @Filename='F:Oracle.txt',@Flag=@flag OUT |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-16 : 00:52:23
|
| the parameter @SqlStatement should be of nvarchar type rather than varchar.also dont use sp_ for procedure names |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
siprem
Starting Member
6 Posts |
Posted - 2008-12-16 : 00:57:14
|
| Thanks, I got the reason . The procedure sp_executeSql expects nvarchar type. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|