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
 Transact-SQL (2000)
 Using sp_executesql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-31 : 00:16:50
Stingray writes "Using the Pubs database...

What is wrong with this statement?

sp_executesql N'select au_id, au_lname, au_fname from authors order by 2 @P1', N'@P1 varchar(3)', @P1 = 'ASC'

When trying to execute this, I get the very useful message "Line 1: Incorrect syntax near '@P1'.

SQL 7 (sp2)
Windows NT 4.0 (sp6a)

Thanks for any help."

Nazim
A custom title

1408 Posts

Posted - 2002-01-31 : 00:43:10
@P1 variable is there in the select statement after order by 2 giving incorrect syntax. Do away with it

sp_executesql N'select au_id, au_lname, au_fname from authors order by 2', N'@P1 varchar(3)', @P1 = 'ASC'

quote:

sp_executesql N'select au_id, au_lname, au_fname from authors order by 2 @P1', N'@P1 varchar(3)', @P1 = 'ASC'



HTH

--------------------------------------------------------------
Dont Tell God how big your Problem is , Tell the Problem how Big your God is
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-01-31 : 08:45:46
see
www.nigelrivett.com
sp_executesql

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -