Hello,
Setting parameter ranges for a query is very useful.
How can I specify : begins with ..... and make that a parameter (in this
case first 5 digits of a project name)?
Liek '%[parameter3]%' does not work.
What should it be?
Help much appreciated,
An 'over-his-head' Texas Tonie
Texas Tonie,
If you want a range of values, look at the BETWEEN operator. For character
strings, however, the whole issue of collation and sort order needs to be
considered when defining what is between.
For your example problem, assuming that the 'number' is actually a character
string (not some sort of numeric datatype) and that the number may have
leading spaces, then you could use:
DECLARE @.Value = ' 12345'
SELECT @.Value WHERE LTRIM(@.Value) LIKE '12345%'
FWIW,
RLF
"Texas Tonie" <TexasTonie@.discussions.microsoft.com> wrote in message
news:72C622EC-3C49-41C7-8259-2274E9396CD3@.microsoft.com...
> Hello,
> Setting parameter ranges for a query is very useful.
> How can I specify : begins with ..... and make that a parameter (in this
> case first 5 digits of a project name)?
> Liek '%[parameter3]%' does not work.
> What should it be?
> Help much appreciated,
> An 'over-his-head' Texas Tonie
Showing posts with label digits. Show all posts
Showing posts with label digits. Show all posts
Thursday, March 29, 2012
Monday, March 19, 2012
Add two digits to the front?
Hi all,
I have a number like so 778625 and want to make
this a more meaningful date (UK) so how difficult is it to
add two digits in this case 19 to the front of this number?
Many thanks
SamThis is a date? I'm not sure I understand how 1977 is any more meaningful
than 77, when the rest of the number is 8625. But okay, I suppose you could
do this:
DECLARE @.i INT
SET @.i = 778625
SELECT '19'+CAST(@.i AS VARCHAR)
And if you have to do it conditionally, say if the first two digits are less
than 30 you assume it's 20xx, then
DECLARE @.i INT, @.ivc VARCHAR(12)
SELECT @.i = 778625, @.ivc = CAST(@.i AS VARCHAR(32))
SELECT CASE WHEN CONVERT(TINYINT, LEFT(@.ivc, 2))>=30 THEN '19' ELSE '20' END
+ @.ivc
"Sam" <sgpgpjr@.yahoo.ie> wrote in message
news:082a01c3462b$f1924960$a001280a@.phx.gbl...
> Hi all,
> I have a number like so 778625 and want to make
> this a more meaningful date (UK) so how difficult is it to
> add two digits in this case 19 to the front of this number?
> Many thanks
> Sam
>
I have a number like so 778625 and want to make
this a more meaningful date (UK) so how difficult is it to
add two digits in this case 19 to the front of this number?
Many thanks
SamThis is a date? I'm not sure I understand how 1977 is any more meaningful
than 77, when the rest of the number is 8625. But okay, I suppose you could
do this:
DECLARE @.i INT
SET @.i = 778625
SELECT '19'+CAST(@.i AS VARCHAR)
And if you have to do it conditionally, say if the first two digits are less
than 30 you assume it's 20xx, then
DECLARE @.i INT, @.ivc VARCHAR(12)
SELECT @.i = 778625, @.ivc = CAST(@.i AS VARCHAR(32))
SELECT CASE WHEN CONVERT(TINYINT, LEFT(@.ivc, 2))>=30 THEN '19' ELSE '20' END
+ @.ivc
"Sam" <sgpgpjr@.yahoo.ie> wrote in message
news:082a01c3462b$f1924960$a001280a@.phx.gbl...
> Hi all,
> I have a number like so 778625 and want to make
> this a more meaningful date (UK) so how difficult is it to
> add two digits in this case 19 to the front of this number?
> Many thanks
> Sam
>
Friday, February 24, 2012
add digits to the front
Hi all,
I have a number like so 778625 and want to make this a more meaningful
date (UK) so how difficult is it to add two digits in this case 19 to
the front of this number?
I have a number like so 778625 and want to make this a more meaningful
date (UK) so how difficult is it to add two digits in this case 19 to
the front of this number?
Many thanks
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!actually i don't need it to be a date i just need to add 19 to the front
of the number.
Thanks again
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||You can do:
SELECT CAST(CAST(19 AS VARCHAR) + CAST(778625 AS VARCHAR) AS INT)
Another option is to do:
SELECT 19 * POWER(10, LEN(778625)) + 778625
--
- Anith
( Please reply to newsgroups only )|||Not really sure what you mean but something like
select convert(int,'19'+convert(varchar(10),fld))
--
Posted via http://dbforums.com
Subscribe to:
Posts (Atom)