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
 Assign function to table var??

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-09-19 : 16:46:06
I keep getting a declare error on this:
DECLARE @SplitTable TABLE(Idx BIGINT IDENTITY(1,1), SplitData VARCHAR(20), Size INT)
SET @SplitTable = dbo.SplitToTable('|', '1|One|0:26:20|541|abc|xxx|6:26:33|21705')

All I want to do is assign the table that my function returns to a variable. Should be easy, but I tried the above and assigning with 'as':

select * from dbo.SplitToTable('|','1|One|0:26:20|541|abc|xxx|6:26:33|21705') as Split

that didn't work either.

Also tried:
DECLARE @SplitTable TABLE(Idx BIGINT IDENTITY(1,1), SplitData VARCHAR(20), Size INT)
select @SplitTable= from dbo.SplitToTable('|','1|One|0:26:20|541|abc|xxx|6:26:33|21705')

what am I missing?

--PhB

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-19 : 16:49:05
An INSERT statement?

INSERT @SplitTable (SplitData, Size)
SELECT Data, LEN(Data) FROM dbo.SplitTable('|','1|One|0:26:20|541|abc|xxx|6:26:33|21705') AS Split



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-09-19 : 16:49:20
you have to an INSERT INTO SELECT * FROM dbo.function



Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-09-19 : 16:53:38
Yes! Thanks.

I just figured out you can do a select into a temp table.

Why do I always come up with an answer right after I click submit?

--PhB
Go to Top of Page
   

- Advertisement -