March 31, 2010 at 8:16 am
I am having trouble passing a variable into my sql statement. Best way of explaining is show a script.
declare @extract varchar(10), @extract2 varchar(10)
set @extract = '2,4'
select SUBSTRING('Hello Paul', @extract)
March 31, 2010 at 8:21 am
there's two ways to do it Paul; the best way is to parameterize the integers:
declare @extract varchar(10),@Start int,@length int
set @Start =2,@length =4
select SUBSTRING('Hello Paul', @Start ,@length )
to do it the way you had it, you'd have to revert to dynamic sql, and you'll want to avoud that for something so simple.
Lowell
March 31, 2010 at 8:31 am
Fantastic, thank you
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply