December 17, 2012 at 8:51 pm
Comments posted to this topic are about the item Table variables
Igor Micev,My blog: www.igormicev.com
December 17, 2012 at 9:21 pm
An easy one for the day!
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
December 17, 2012 at 11:47 pm
Easy qstn to start the day.
--
Dineshbabu
Desire to learn new things..
December 17, 2012 at 11:50 pm
+1
December 17, 2012 at 11:59 pm
December 18, 2012 at 12:24 am
Easy one, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
December 18, 2012 at 12:37 am
This was removed by the editor as SPAM
December 18, 2012 at 1:29 am
Thanks for the question.
Can I ask that they are all like this until the New Year?
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
December 18, 2012 at 2:44 am
Oof! That was a tough one, after using up my 50/50 I had to call a friend! Maybe it was a trick question.
Alas no, a nice easy one for this morning, and very much appreciated.
Good question thanks.
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
December 18, 2012 at 2:55 am
In case anybody wonders, on a similar note...
Can table valued parameters be used in a function?.
.
.
.
Yes!
and they are very useful fo creating functions that take name-value-pairs
e.g.
CREATE TYPE [dbo].[AuditNVP] AS TABLE(
[Name] [varchar](128) NULL,
[Value] [sql_variant] NULL
)
CREATE FUNCTION fnc (@AuditNVP AuditNVP READONLY)
RETURNS int
AS
BEGIN
DECLARE @ReturnValue int
-- Do something with the NVP (hopefully somehting more useful than this)
SELECT @ReturnValue = COUNT(*) FROM @AuditNVP
RETURN @ReturnValue
END
Then in sql code
DECLARE @AuditNVP AuditNVP
INSERT INTO @AuditNVP (Name, Value) VALUES ('Item',1)
INSERT INTO @AuditNVP (Name, Value) VALUES ('Item',2)
SELECT dbo.fnc(@AuditNVP) -- get count of items. Pointless but proves a point
David Bridge
David Bridge Technology Limited
www.davidbridgetechnology.com
December 18, 2012 at 4:19 am
Greatly appreciated easy question after I struggled with yesterdays.
December 18, 2012 at 6:02 am
Nice easy one today.
Perhaps it would have been a good idea to provide the appropriate BoL reference: CREATE FUNCTION (Transact-SQL) which contains the statement
In multistatement table-valued functions, @return_variable is a TABLE variable, used to store and accumulate the rows that should be returned as the value of the function
and that answers the question rather clearly - if some functions have to use a table variable, then certainly functions can use table variables.
Tom
December 18, 2012 at 6:34 am
Also:
table variables can be used in functions, stored procedures, and batches.
December 18, 2012 at 6:37 am
So is someone going to ask tomorrow if we can use temp tables in UDFs?
December 18, 2012 at 6:48 am
Nice and easy thank you.
Viewing 15 posts - 1 through 15 (of 25 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy