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)
 EXECUTE SQL String with Return Value

Author  Topic 

charlesmorris
Starting Member

11 Posts

Posted - 2001-06-27 : 18:47:42
Ok, I'm a part-time SQL developer and I'm stuck on something that seems like it should be simple. I've stripped all the unnecessary code out of my example except the applicable and offensive code =)

Given SQL Server6.5 and the following SQL:
=========================================

CREATE PROCEDURE sp_THISSUX AS

declare @strOutput varchar(255)
declare @SQLString varchar(255)

Set @SQLString = 'Select @strOutput = data from mycooldatabase'
EXEC @SQLString @StrOutput OUTPUT

==========================================

What happens is SQL Server looks for a SP called:

'Select @strOutput = data from mycooldatabase'

It throws an error saying the SP does not exist (well duh) as opposed to
just executing the string.

How is this done? I understand that in SQL7/2000 there is a SP called sp_ExecuteSQL that will fix my problem, but were running on 6.5 still...

TIA,
Charles

   

- Advertisement -