you are missing the FROM clause. you can't select a column name without it's table.
SpeedSkaterFan (11/30/2015)
Hi all,I am trying to split (incorrect) cellcontents into smaller pieces.
If I use:
SELECT cdsDescription
, CHARINDEX(' ',cdsDescription) AS [1stPos]
, CHARINDEX(' ', cdsDescription, CHARINDEX(' ',cdsDescription) + 1) AS [2ndPos]
[highlight="#ffff11"]FROM tbCompdistances[/highlight]
the code works fine.
If I try to simplify the code (which will grow) for easier reading, and try to use a variable SQL Server states that "cdsDescription" is an invalid column name.
The code I use:
DECLARE @FirstBlankPosition INTEGER
SET @FirstBlankPosition = CHARINDEX(' ', [cdsDescription], 1)
[highlight="#ffff11"]FROM tbCompdistances[/highlight]
Is it possible to do what I want, or is the code invalid.
Thanks in advance
Hein
Lowell