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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sp_executesql, cannot execute string vith params ?

Author  Topic 

marconi8
Yak Posting Veteran

73 Posts

Posted - 2003-05-12 : 07:03:22
strange, but maybe i have something dont understand but why this dont work for me ??


declare @SQL NVARCHAR(1000)

@SQL=''

sorry i have posted more strings !!!!


hm,

EXECUTE SP_EXECUTESQL N'SELECT TOP @C_COUNT ID FROM TEST_A',
N'@C_COUNT INT',
@C_COUNT=10

i'am only trying to understand what of this statement have error,
for example if i'am writing this


SET @C_COUNT=10
SET @SQL='
SELECT TOP '+CAST (@C_COUNT AS VARCHAR)+' ID FROM TEST_A
'
EXECUTE SP_EXECUTESQL @SQL

then this works

















Edited by - marconi8 on 05/12/2003 07:42:33

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-05-12 : 07:13:39
quote:
@sql=''

This is not valid sql syntax. Variables are assigned values in T-SQL by useing the SELECT or SET commands.

Jay White
{0}
Go to Top of Page
   

- Advertisement -