Re: Need to make Sort ORDER in SP defined by Input variable
From: Larry Woods (larry_at_NOSPAMlwoods.com)
Date: 06/26/04
- Next message: Larry Woods: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Previous message: Steve Kass: "Re: Need to make Sort ORDER in SP defined by Input variable"
- In reply to: Pablo: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Next in thread: Steve Kass: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Reply: Steve Kass: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Reply: Pablo: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 26 Jun 2004 10:26:20 -0700
Nope!
If I enter 'ISBN' (w/o quotes) when I execute the SP below, it executes,
showing the correct number of lines, but I get NO fields displayed.
Original SELECT line:
SET @SQL = 'SELECT ISBN FROM tblISBNs WHERE ISBN = ''0021465614'' ORDER BY '
+ @sortorder
If I modify toe SELECT from this to this:
SET @SQL = 'SELECT ISBN FROM tblISBNs WHERE ISBN = ''0021465614'' ORDER BY
ISBN'
it works fine!!!!!
Here is the complete SP:
ALTER PROCEDURE dbo.cbe_ISBNActivityHits
(
@sortorder nvarchar(50)
)
AS
SET NOCOUNT ON
DECLARE @SQL nvarchar(400)
SET @SQL = 'SELECT ISBN FROM tblISBNs WHERE ISBN = ''0021465614'' ORDER BY '
+ @sortorder
EXEC sp_executesql @SQL
"Pablo" <Pablo@discussions.microsoft.com> wrote in message
news:BD76972A-DC2F-406A-AC2A-0AECA2DA681C@microsoft.com...
> Use Northwind
> go
> DECLARE @SQL NVARCHAR(1024)
> DECLARE @Column NVARCHAR(64)
>
> Set @Column='LastName'
> SET @SQL='SELECT * FROM dbo.Employees ORDER BY '+@Column
>
> exec sp_executesql @SQL
>
>
> Pablo
>
>
> "Larry Woods" wrote:
>
> > Help.... I'm back!
> >
.........................................
- Next message: Larry Woods: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Previous message: Steve Kass: "Re: Need to make Sort ORDER in SP defined by Input variable"
- In reply to: Pablo: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Next in thread: Steve Kass: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Reply: Steve Kass: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Reply: Pablo: "Re: Need to make Sort ORDER in SP defined by Input variable"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|