January 16, 2012 at 6:10 am
Hi all,
If a table contain no records and if I write the statement as insert in functions and I also written it in the stored procedure, so, what will be the result for both?
can anybody explain this?
January 16, 2012 at 6:26 am
I dont understand your question. Can you rephrase please?
January 16, 2012 at 6:28 am
niha.736 (1/16/2012)
Hi all,If a table contain no records and if I write the statement as insert in functions and I also written it in the stored procedure, so, what will be the result for both?
can anybody explain this?
User-defined functions cannot be used to perform actions that modify the database state.
http://msdn.microsoft.com/en-us/library/ms186755.aspx
An error whilst attempting to create the function - unless it's a table variable.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 16, 2012 at 6:32 am
niha.736 (1/16/2012)
Hi all,If a table contain no records and if I write the statement as insert in functions and I also written it in the stored procedure, so, what will be the result for both?
can anybody explain this?
If I'm reading your question correctly, then NO.
just to be clear, in SQL , a function can only return data. it cannot INSERT or UPDATE any data.
functions are limited to not allowing " "side affecting operations", which includes inserts and updates.
A procedure can do it, as you identified.
Lowell
January 16, 2012 at 6:37 am
:Wow: i got my clarification, many thanks mr.Lowell
January 16, 2012 at 6:42 am
niha.736 (1/16/2012)
:Wow: i got my clarification, many thanks mr.Lowell
No problem, glad i could help;
If you are coming from a programming background, Functions and Subs are interchangable, and the only difference is whether you returna value or not.
In TSQL, the are a special, limited type of procedure.
I think Chris@Home provided a good detail link if you need to read up on it a bit more.
Lowell
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply