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.
Author |
Topic |
jtwork
Yak Posting Veteran
82 Posts |
Posted - 2007-09-26 : 10:04:32
|
in the select part of my query i want to provide a column like so1-5The parameters for the criteria's are varchar as the help files suggest that i cannot cast a int to text.I cant get the below to work through...any ideas??cast(@Min_Criteria as text) + '-' + cast(@Max_Criteria as text) as Criteria |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-26 : 10:09:24
|
cast(@Min_Criteria as text) + '-' + cast(@Max_Criteria as text) as Criteriashould becast(@Min_Criteria as varchar(20)) + '-' + cast(@Max_Criteria as varchar(20)) as CriteriaMadhivananFailing to plan is Planning to fail |
|
|
rekiller
Starting Member
31 Posts |
Posted - 2007-09-26 : 10:10:08
|
[code]declare @min_criteria intdeclare @max_criteria intset @min_criteria=1set @max_criteria=5select cast(@min_criteria as varchar(10))+'-'+cast(@max_criteria as varchar(10)) as Result[/code]Or[code]declare @min_criteria intdeclare @max_criteria intdeclare @result varchar(10)set @min_criteria=1set @max_criteria=5set @result=cast(@min_criteria as varchar(10))+'-'+cast(@max_criteria as varchar(10))select @result[/code]Does this help?quote: Originally posted by jtwork in the select part of my query i want to provide a column like so1-5The parameters for the criteria's are varchar as the help files suggest that i cannot cast a int to text.I cant get the below to work through...any ideas??cast(@Min_Criteria as text) + '-' + cast(@Max_Criteria as text) as Criteria
|
|
|
jtwork
Yak Posting Veteran
82 Posts |
Posted - 2007-09-26 : 10:15:05
|
Many thanks all |
|
|
|
|
|