Showing posts with label urgent. Show all posts
Showing posts with label urgent. Show all posts

Wednesday, March 21, 2012

hi, i need ur urgent help immediately(!)

i have a sql data table which icludes names and surnames

as like as that:

george read

hasan hujtr

deem greg

ade ad

edy es

-----

i need a "select" query to receive only people whom surnames composed merely two letters(ade ad, edy es).

thanks,

best regards.

Do you mean two letters or two words?

|||

I don't think the length() function is supported in sql server... but a hack for that if you're just looking for 2 letters or less would be:

select *
from names
where substring(surname,0,2) = surname

|||^^^ I do believe that will return surnames of length 1 too though... so try it.|||

Don't mean to spam, but I was wrong... there is a length function...

select *
from names
where len(surname) = 2

|||

thanks for ur helps

best regards.

Monday, March 19, 2012

hi

hi any one please send me to how to convert dtd files to sql server filea its urgent please send me the procedure about that oneQuestion moved to SQL Server Forum.

Friday, February 24, 2012

Help: Join few records in a same field and same database table.

Hi guys,

I need urgent help here. How to join few records in a same field and same database table. For example:

id sequence_no itemcode description
1 1 APP Apple
1 2 BNN Banana
2 1 ORG Orange

What is the sql query that will return row as follow:

id description
1 Apple Banana
2 Orange

Thank you in advance guys...

hi, you can try this

-- create a function
CREATE FUNCTION dbo.GetFruitSequence
(
@.id int
)
RETURNS varchar(100)
AS
BEGIN
DECLARE @.FruitSequence varchar(100)
SET @.FruitSequence = ''

SELECT @.FruitSequence = @.FruitSequence + [description] + ', '
FROM Fruits
WHERE [id] = @.id
ORDER BY
[sequence_no]

IF @.FruitSequence <> '' SET @.FruitSequence = LEFT(@.FruitSequence, LEN(@.FruitSequence) - 1)

RETURN @.FruitSequence

END

GO

-- to use the function
SELECT DISTINCT [id]
, dbo.GetFruitSequence([id]) as [description]
FROM Fruits
ORDER BY
[id]

GO|||Thank you Rhamille|||

You can use the following query in SQL Server 2005

Code Snippet

Create Table #itemdata (

[id] int ,

[sequence_no] int ,

[itemcode] Varchar(100) ,

[description] Varchar(100)

);

Insert Into #itemdata Values('1','1','APP','Apple');

Insert Into #itemdata Values('1','2','BNN','Banana');

Insert Into #itemdata Values('2','1','ORG','Orange');

Select

id

,(Select [description] + ' ' as [text()] From #itemdata as Sub Where Sub.id=Main.id For XML Path(''), ELEMENTS) as List

From

#itemdata as Main