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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 where is error in my function

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-07-24 : 01:03:17
Dear experts,
please tell me where is the error in my code?

create function getitemid(@uomid varchar(50))
returns table
as begin
declare @itemid varchar(50)
select @itemid= column01 from table21 where column03=(select dbo.getuomid('no of leaves'))
return (@itemid)
end
go

Vinod
Even you learn 1%, Learn it with 100% confidence.

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-07-24 : 01:14:50
you have declared the function will return Table but it returns varchar

--------------------------------------------------
S.Ahamed
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-07-24 : 01:18:34
create function getitemid(@uomid varchar(50))
returns varchar(50)
as begin
declare @itemid varchar(50)
select @itemid= column01 from table21 where column03=(select dbo.getuomid('no of leaves'))
return (@itemid)
end
go
now it is giving one value.
actually that will give the values around 280. i need all the 280 values

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-07-24 : 01:35:30
Use inline table-valued function

create function getitemid(@uomid varchar(50))
returns table
as
Return(select column01 from authors where column03=(select dbo.getuomid('no of leaves')))

--------------------------------------------------
S.Ahamed
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-24 : 02:22:29
create function getitemid(@uomid varchar(50))
returns table
as
Return(select column01 from authors where column03=dbo.getuomid('no of leaves'))


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-07-24 : 02:50:35
dear folks,
now it's as per my requirement, that i'm getting the 280 values.

now i've to update one table based on these results.

I've to put all the 280 rows (i mean only one column in the format) in columnb2 of table19 like

insert into table19.columnb2 select * from dbo.getitmid('1ca7a0fa-c507-4d4d-94a1-13eb9ec3d6d2')
please give me the query or procedure


thanks in advance

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-24 : 02:54:37
It would be much easier if you posted your FULL and COMPLETE problem description the first time.
Now we have to read this topic over and over again! Complete waste of time...

You should use UPDATE if you want to UPDATE "one table". For this, you need to know how to bind the two resultset together.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-07-24 : 02:58:48
Dear Peso,
I've already posted the entire requirement. but i dont know why i was unable to get help from you all. i thought it was because of me(may be failed to give you the proper information)
that's why i've tried in different ways, and posted like that....sorry for troubling.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86530

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-24 : 03:02:39
Duplicate post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86530


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -