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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Create View and UDF error

Author  Topic 

ghost7
Starting Member

3 Posts

Posted - 2011-04-08 : 06:06:47
Hi all

I have big problem with creating a view with Table-valued function.

Function:

create FUNCTION [dbo].[GetValue]()
RETURNS @tab TABLE (jid uniqueidentifier)
AS
begin
insert into @tab
SELECT JID
FROM dbo.Contacts
WHERE user = suser_sname()

return
end

When I use the ADD table wizard and ADD the function to the view it puts this statement into sql:

SELECT jid FROM dbo.GetValue(,) AS GetValue_1

When I execute the sql it returns an error:

Incorrect syntax near ','
and
Incorrect syntax near ')'

Can U please help me??? I need to have a view, because other applications will collect the data. I spend many hours searching for this, but no solution found.

Thanks in advance

Ghost7

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-08 : 07:17:58
Looks like you have an extra comma that is causing the problem.
SELECT jid FROM dbo.GetValue(,) AS GetValue_1


Remove the comma from within the brackets.
Go to Top of Page

ghost7
Starting Member

3 Posts

Posted - 2011-04-08 : 08:04:01
thx for reply

But I already tried it and SQL puts it back automatically with an error:
Incorrect syntax near ')',
already tried to add some parameters, but nothing is working.
I tried to search for some examples but I havent find anything.

I dont know why the SQL automatically rewrites my statement. In New Query works everything fine, but in the views designer it doesnt work.

I tried almost everything...

I am using SQLExpress 2008 with default instance.
Maybe in full SQL (enterprise, standard) it will work, but I dont have them right now...

Thx for any advice
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-04-08 : 08:09:03
If possible then create your view in a normal query editor window without using that designer.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ghost7
Starting Member

3 Posts

Posted - 2011-04-08 : 08:15:40
Hi to all

Thx for all replies, Reinstalled sql and I have created new view and everything seems to work..

thx again
Go to Top of Page
   

- Advertisement -