Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 638
  • Last Modified:

Error converting data type varchar to float.

With the following query

alter procedure [dbo].[Lots_GetSortedData]
@SortColumn varchar(255),
@Direction varchar(10)
as

declare @SQL varchar(8000)

    BEGIN

       SELECT @SQL = 'select ID, LOT_TITLE, COMPANY_NAME, CITY, STATE, ACTIVE, DESCRIPTION from Lots ORDER BY ' + str(@SortColumn) + ' ' + @Direction

       exec(@SQL)

    END

I get the following error

Msg 8114, Level 16, State 5, Procedure Lots_GetSortedData, Line 12
Error converting data type varchar to float.

How can i fix this?
0
rodmjay
Asked:
rodmjay
1 Solution
 
ptjcbCommented:
Which column is float? I would guess the SortColumn, but without a table description....

Anyway, add a CAST(column as varchar) to the column
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now