Showing posts with label returned. Show all posts
Showing posts with label returned. Show all posts

Sunday, March 25, 2012

Calling sp_StartJob again when the job is running, what would

as far as I know, if you don't handle the error that is returned (I'm not
talking about @.@.error that will be 0 anyway), the insert and the trigger
will finish alright.
"Frank Lee" wrote:

> I do not understand what 'Error message will be raised and the trigger wil
l
> still be executed' means.
> In this case, If a asp.net server page is connecting by using ado.net, whi
ch
> try to insert a new record to MyTable by calling a SP named MyInsert, will
> this asp.net server page get the error message, be hang up and just show u
p
> the default error page?
> If the asp.net server page will hang up, is there a way to mask this error
> message?
> I mean, no matter the MyJob is running or not, I would like the client (th
e
> server page) insert a new record smoothly. Never got this Error Message.
> So I hope that you say 'Error message will be raised and the trigger will
> still be executed' means that '@.@.error would be set and if there is no
> consideration to care this @.@.error, the trigger will still be executed
> quietly'.
> If not, how can I prevent the error message?
>
> "ariel" <ariel@.discussions.microsoft.com> ???g?ó?l¥ó·s?D:5C8009A
2-126D-4BA3-8D01-54935DC5BD71@.microsoft.com...
>
>Thanks. I see.
"ariel" <ariel@.discussions.microsoft.com> glsD:ABF0F938-1630-4794-BE3E-2651812831
9B@.microsoft.com...
> as far as I know, if you don't handle the error that is returned (I'm not
> talking about @.@.error that will be 0 anyway), the insert and the trigger
> will finish alright.
> "Frank Lee" wrote:
>

Thursday, March 22, 2012

Calling Functions

Dear Everybody,

Hi again!

Supposing I have an SQL Server Function named Fxn1 which returns a VARCHAR(6) value. I want to use this returned value in another function named Fxn2 but Fxn2 accepts a parameter of type INT. Fxn2 itself returns an INT value. This has to be achieved in a single line.

The following line of code will not work in SQL Server. How should I achieve this?

declare @.Res INT
EXEC @.Res = Fxn2 (CONVERT( INT, Fxn1 ))

Thanx in advance!Just curioius, but have you tried talking to the TA or your instructor? Its really important that you talk to them when you are stumped on homework, they need the feedback as much as you need the help finding the solution.

-PatP|||No thx for the suggestion. :rolleyes:

I always thought that this forum had people who cud come up with suggestions which were technical in nature!|||It does, but we still won't do your homework!

-PatP|||First of all stop calling this homework. You cannot pass judgements like that. To me it was a genuine problem that's why I referred it to this forum. Might be not for u.

If u r not interested, gr8. But keep ur thoughts to urself.|||"This has to be achieved in a single line."?

Are you running out of lines on your computer?

You may just need to create a single function that combines the logic of the two you have.|||I don't have any problem giving legitimate help (read a few thousand of my posts if you'd like to confirm that), but based on the attitude that you've displayed and the grammer and spelling that you've used (or more accurately failed to use), you appear to me to be a rather rude kid that is sqawking because they got caught trying to get someone to do their homework. If I've misinterpreted something, I'm sorry, but that is how you appear to me at the moment.

Based on the way you presented the question in your original posting, it reads like homework. Are you saying that it isn't homework? If not, can you give us a little background in what you are trying to do, and more importantly why it needs to be accomplished in a single line?

-PatP|||Are you running out of lines on your computer?I just hate it when that happens, don't you?

-PatP|||What error are you getting when you execute the statement? Obviously
EXEC @.Res = Fxn2 (CONVERT( INT, Fxn1 ))
...will error out if Fxn1 returns a string that cannot be converted to an INT.
Also, post the actual statement you are sending.|||Dear blindman (although I hate to use that term to address u),

First of all thx for ur concern & help. Can I show the audacity to ask your real name?

Second of all, lets move to my actual problem..

I have several procedures and functions in Oracle which I have to convert to SQL Server syntax. The Fxn1 and Fxn2 names that I had used was just to present the problem to the forum in a simple manner.
In one of the functions named CREATE_TRIPS_SCHED, a SELECT statement has been included (the result of which has been used in another query) which is as follows :

SELECT 'P'||T.T_ID, T.S_TIME, T.END_TIME,
NVL(T.DESIRED_TIME, MIN_TO_AMPM( TO_MINUTES(TO_NUMBER(AMPM2FULLHRS(T.EST_TIME))))),
T.DISP, DECODE(T.WHEEL_CHAIR,'Y',5,2)
FROM DISPATCH_TRIPS T
WHERE T.R_NUM LIKE 'X%'

In the above statement, MIN_TO_AMPM, TO_MINUTES and AMPM2FULLHRS are all UDFs, out of which MIN_TO_AMPM and TO_MINUTES fxns return INTEGER values and AMPM2FULLHRS returns a VARCHAR value.

The conversion for SQL Server that I had done is as under :

SELECT 'P' + T.T_ID, T.S_TIME, T.END_TIME,
(CASE T.DESIRED_TIME WHEN ISNULL THEN MIN_TO_AMPM( TO_MINUTES(CONVERT (INT, AMPM2FULLHRS (T.EST_TIME)))) ELSE T.DESIRED_TIME END),
T.DISP, (CASE T.WHEEL_CHAIR WHEN 'Y' THEN 5 ELSE 2 END)
FROM DISPATCH_TRIPS T
WHERE T.R_NUM LIKE 'X%'

And the error msg that I am getting is this :

Server: Msg 195, Level 15, State 10, Procedure CREATE_TRIPS_SCHED, Line 25
'AMPM2FULLHRS' is not a recognized function name.
Server: Msg 156, Level 15, State 1, Procedure CREATE_TRIPS_SCHED, Line 56
Incorrect syntax near the keyword 'END'.
Server: Msg 156, Level 15, State 1, Procedure CREATE_TRIPS_SCHED, Line 68
Incorrect syntax near the keyword 'END'.

I have to do this conversion without introducing other fxns of mine. So, this is the actual problem. I hope I have been able to get across my problem!

Thx again! :)|||Pat,

At least you had the decency to be 'sorry' even if my turning 'rude' prompted you to do so.

Originally Posted by Pat Phelan
It does, but we still won't do your homework!
Having a few thousand posts does not give you the right to be judgemental. It also does not entitle you to speak on behalf of the whole forum.

P.S. Are u always like that?|||Perhaps adding the owner of the function when calling the function helps (db.owner.function)?|||It appears that my first impression may have been wrong. Based on your last post to blindman, you do seem to have a good grasp of SQL and a practical reason for making your original request.

I think you should have success if you use:SELECT @.Res = dbo.Fxn2 (CONVERT( INT, dbo.Fxn1() ))This ought to safely degenerate into:SELECT @.Res = dbo.Fxn2 (dbo.Fxn1() )In answer to your other question, yes, especially when this forum is barraged with kids looking for someone to do their homework for them, I tend to react with considerable skepticism to posts that are presented that way. My intent is to "red flag" those posts for other forum members, so that they will consider whether they want to spend their time working on a problem that is likely going to be turned in by a kid with no appreciation and no clue. The other forum members can use their own judgement, I'm just trying to make sure that they think before they "burn daylight" answering a post that I perceive as looking for an opportunity to plagerize.

I've repeatedly had my work turned in by students, whose teachers have recognized my style and contacted me. That probably makes me overly sensitive to the issue. I also think that there is a real ethical problem there too, and being in a position where ethical behavior is probably more important than technical expertise, that is very important to me.

Based on the begining of this thread, I had no reason to suspect that you were anything other than an apprentice juvenile delinquent, trolling to find someone that would do their assignment for them. Based on your post to Blindman, it appears that my first impression was wrong, so I responded differently in this post. As I've said before, I have no problem giving legitmate technical assistance, but I outright refuse to allow someone to take advantage of me (or anyone else without their approval).

-PatP|||Knighthassan,

Pat, myself, and others have given literally thousands of bits of advice and help to people who have posted on these boards, all of it free. If Pat made a mistake about your situation then so be it, but he had reasons to be suspicious. People asking for free advice should be less disrespectful, especially of people like Pat who is arguably the most knowledgable SQL Server expert on this forum. The fact that he took considerable time to review your complex code and propose a solution after last few posts you made shows how gracious he is. I hope his solution was helpful.|||blindman and Pat,

Thx to u both my problem is resolved. I also realize that my language has been a bit too harsh at times but something there got to me. Anyways, no hard feelings and thx again.|||blindman and Pat,

Thx to u both my problem is resolved. I also realize that my language has been a bit too harsh at times but something there got to me. Anyways, no hard feelings and thx again.No problem, and I'm glad that your problem has been fixed.

I rarely miss on issues like this, but of course when I do then it's a doozie. Out of several hundred "homework" calls that I've made, this is only the second one that I know where my initial call was wrong.

Right now I'm probably overly sensitive to it, since American schools are just coming back from the Thanksgiving holiday which meant that quite literally tens of thousands of assignments were due last week.

I noticed that you'd dived into some other message threads and contributed to them too. I hope that you decide to stick around and join in the fun! Lord knows that there is no shortage of questions, and it always helps to have a different perspective (although mine is usually quite "different" all by itself!).

-PatP|||I'm glad we (mosty Pat) were able to assist you, and yeah working with databases can be frustrating in itself sometimes, but we try to keep things light on this forum so no hard feelings and post again with both questions and advice.|||Pat, myself, and others have given literally thousands of bits of advice and help to people who have posted on these boards, all of it free.

Thank you

If Pat made a mistake about your situation then so be it, but he had reasons to be suspicious.

Umm, maybe not

People asking for free advice should be less disrespectful

Absolutely...why do people get so worked up? Who cares what soemone says? This always cracks me up.

especially of people like Pat who is arguably the most knowledgable SQL Server expert on this forum.

Well, could be, but I know Nigel posts here from time to time.

The fact that he took considerable time to review your complex code and propose a solution after last few posts you made shows how gracious he is. I hope his solution was helpful.

I think he'd still be having trouble. Post the actuall CREATE FUNCTION statements for both functions...personally they look more like a sproc to me...

And as for B. Lindman, you could probaly say "Yo, Blind dude!"

I always wondered where he got a braille keyboard..|||And as for B. Lindman, you could probaly say "Yo, Blind dude!"

I always wondered where he got a braille keyboard..Ah, Braille keyboards are no biggie to get. The difference is only in a few keys, but the tactile feedback for the indicators is the challenging part.

-PatP|||Wut's tuff iss finding a ceeing I dogg thata caan tipe woof a dam.

Bad dog! Bad!|||Originally Posted by Brett Kaiser
I always wondered where he got a braille keyboard..

A braille display and a braille mouse too! The world gets curiouser and unfathomable each passing day..

:D|||A braille display and a braille mouse too! The world gets curiouser and unfathomable each passing day..You say that as though it were a bad thing! ;)

As a side note, couldn't you get into some kind of trouble for feeling the bumps on a Braille mouse in the office ?

-PatP|||Depends on what you mean by mouse...

Sunday, March 11, 2012

Calling a Stored Procedure from a strored Procedure

Hi,
I want call a stored procedure A that reurns a single value from another
Stored Proc B. Stored Proc B must use the returned value from Stored Proc A
as an input
SOS
create proc usp_SprocB
as
return -1
go
create proc usp_SprocA
as
declare @.retValB int
exec @.retValB = usp_SprocB
return @.retValB * 105
go
declare @.retVal int
exec @.retVal = usp_SprocA
select @.retVal
hth
Eric
Givosky wrote:
> Hi,
> I want call a stored procedure A that reurns a single value from
> another Stored Proc B. Stored Proc B must use the returned value from
> Stored Proc A as an input
> SOS
|||Hi ,
I used the other option.
I made Stored Proc A a Function A
and call it from Stored Proc B
e.g
Stored Proc B
Select * from
XX where XX.ID in (Select * from Function A(Param1) )
"Eric Sabine" wrote:

> create proc usp_SprocB
> as
> return -1
> go
> create proc usp_SprocA
> as
> declare @.retValB int
> exec @.retValB = usp_SprocB
> return @.retValB * 105
> go
> declare @.retVal int
> exec @.retVal = usp_SprocA
> select @.retVal
> hth
> Eric
>
> Givosky wrote:
>
>

Calling a Stored Procedure from a strored Procedure

Hi,
I want call a stored procedure A that reurns a single value from another
Stored Proc B. Stored Proc B must use the returned value from Stored Proc A
as an input
SOScreate proc usp_SprocB
as
return -1
go
create proc usp_SprocA
as
declare @.retValB int
exec @.retValB = usp_SprocB
return @.retValB * 105
go
declare @.retVal int
exec @.retVal = usp_SprocA
select @.retVal
hth
Eric
Givosky wrote:
> Hi,
> I want call a stored procedure A that reurns a single value from
> another Stored Proc B. Stored Proc B must use the returned value from
> Stored Proc A as an input
> SOS|||Hi ,
I used the other option.
I made Stored Proc A a Function A
and call it from Stored Proc B
e.g
Stored Proc B
--
Select * from
XX where XX.ID in (Select * from Function A(Param1) )
"Eric Sabine" wrote:
> create proc usp_SprocB
> as
> return -1
> go
> create proc usp_SprocA
> as
> declare @.retValB int
> exec @.retValB = usp_SprocB
> return @.retValB * 105
> go
> declare @.retVal int
> exec @.retVal = usp_SprocA
> select @.retVal
> hth
> Eric
>
> Givosky wrote:
> > Hi,
> >
> > I want call a stored procedure A that reurns a single value from
> > another Stored Proc B. Stored Proc B must use the returned value from
> > Stored Proc A as an input
> >
> > SOS
>
>

Calling a Function from a Stored Procedure

Hello all,

I'm trying to construct a select statement in a stored procedure that filters based on the returned values of a number of functions. My function works fine, but when I try to call the function from the stored procedure I get an error.

I'm going to try explain the thought process behind what I'm doing. Hope I make enough sense.
The purpose of the stored procedure is to perform a wildcard search on a tool. The tool contains a number of FK that link to different tables (e.g., manufacturer, vendor). So I'm creating functions that also search the manufacturer and vendor and return the matching IDs.

Example of tool SELECT statement:

SELECT tool_number, tool_descriptionFROM toolWHERE tool_manufacturerIN (UDFmanufacturer_SearchName(@.search_string)

This gives me an error:
'UDFmanufacturer_SearchName' is not a recognized built-in function name.

Function code (removed some wrapping code for simplicity):

SELECT manufacturer_idFROM manufacturerWHERE manufacturer_nameLIKE'%' + @.search_string +'%'
These statements both work if I run a independent query: 
SELECT *FROM UDFmanufacturer_SearchName('mol')

SELECT *FROM toolWHERE tool_manufacturerIN (SELECT *FROM UDFmanufacturer_SearchName('mol'))

This code fails:

SELECT *FROM ato_toolWHERE ato_tool_manufacturerIN (UDFmanufacturer_SearchName('mol')) 
I'm stuck. I haven't been able to find anything that shows me where I'm going wrong. Any thoughts or suggestions are appreciated.

Thanks,
Jay


You have to use a SELECT FROM function and not directly in the IN clause. Also use the prefix "dbo." for the function and see if it helps.

SELECT *FROM toolWHERE tool_manufacturerIN (SELECT *FROMdbo.UDFmanufacturer_SearchName('mol'))
|||

That was it. I thought I could use the function without needing the " SELECT * " in front.

Thanks for your help.

|||

The above post is absolutely correct.

UDFmanufacturer_SearchName is a table valued function (fancy for it returns a table/resultset). If you then think of UDFmanufacturer_SearchName('mol') as being a table, then

SELECT *
FROM ato_tool
WHERE ato_tool_manufacturerIN (UDFmanufacturer_SearchName('mol'))

isn't valid for the same reasons that:

SELECT *
FROM ato_tool
WHERE ato_tool_manufacturerIN (tool_manufacturer)

isn't valid.

So because tables aren't valid where you've placed it, it's looking for a different type of function, like one that returns a string, date, or number. It can't find one, so it says it can't find the function. Also, you should always prefix your function names with 'dbo.' or the correct schema. It may work without it in some places, but I believe syntactically it's wrong (sloppy). Don't be suprised if a service pack, hotfix, or the next version of SQL Server starts to fail on it.|||

Thanks for the explanation, it was helpful.

Hadn't thought about the schema prefix. Will keep it in mind.

Thanks.

Thursday, March 8, 2012

Call udf returning a table variable from a stored proc.

Hi,
I have a udf that returns a table variable. I would like to call this from
a stored procedure using the returned table variable in the select statement
of a cursor.
Kind of like this, this is the stored proc where udfProductionsScheduleWork
is the udf - the udf returns a table variable.
declare @.ext int
declare bigcurs CURSOR for
select wrkschedExtruder from dbo.udfProductionScheduleWork
open bigcurs
fetch bigcurs into @.ext
close bigcurs
deallocate bigcurs
RETURN
I can run the udf by itself and it returns rows.
When I run the above stored proc, I get : "Invalid object name
'dbo.udfProductionScheduleWork'.
Any Thoughts?
SteveYou'll need open and close brackets at the end of the function call
select wrkschedExtruder from dbo.udfProductionScheduleWork()|||Geeze, Thank you very much!
Of course that fixed it.
Steve
"markc600@.hotmail.com" wrote:

> You'll need open and close brackets at the end of the function call
> select wrkschedExtruder from dbo.udfProductionScheduleWork()
>

Wednesday, March 7, 2012

Call Stored Procedure AS400 From SQL Server

Hi,
I have SQL Server 7 with a link server.
When i try to execute a SP from SQL Server, i have this error :
[ OLE/DB provider returned message: [ IBM][Pilote ODBC iSeries
Access][DB2 UDB]SQL0107 - "pack14rexe" is too long. 10 characters
maximum are accepted. ]
I try this : exec recette.recette.pack14rexe.idcb050
I think that it's the '.' but i've try to change with '/' but i have an
another error...
Can you help me?
Thank's
Portekoi
Hi
I don't know specifically about your error, but there seems to be similar
issue with MS Query and the ODBC driver
http://groups.google.com/groups?q=SQ...g=d&hl=en&lr=&
you may want to try the oledb driver:
http://msdn.microsoft.com/library/de..._db2_oledb.asp
or possibly use OPENQUERY (if you do return a rowset from the stored
procedure or add a dummy one to the query).
See also http://support.microsoft.com/kb/218590/
John
"Portekoi" <portekoi@.passion-cinquieme.com> wrote in message
news:1138975377.316513.28700@.g49g2000cwa.googlegro ups.com...
> Hi,
> I have SQL Server 7 with a link server.
> When i try to execute a SP from SQL Server, i have this error :
> [ OLE/DB provider returned message: [ IBM][Pilote ODBC iSeries
> Access][DB2 UDB]SQL0107 - "pack14rexe" is too long. 10 characters
> maximum are accepted. ]
> I try this : exec recette.recette.pack14rexe.idcb050
> I think that it's the '.' but i've try to change with '/' but i have an
> another error...
> Can you help me?
> Thank's
>
> Portekoi
>
|||I can't help you with your problem, But I sure love to know how you configured your linked server.
I am using Client Access Express and can't find any documentation for what the Product Name, Provider String
and Data Source Should be.
Thanks,
Johnny
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet

Call Stored Procedure AS400 From SQL Server

Hi,
I have SQL Server 7 with a link server.
When i try to execute a SP from SQL Server, i have this error :
[ OLE/DB provider returned message: [ IBM][Pilote ODBC iSeries
Access][DB2 UDB]SQL0107 - "pack14rexe" is too long. 10 characters
maximum are accepted. ]
I try this : exec recette.recette.pack14rexe.idcb050
I think that it's the '.' but i've try to change with '/' but i have an
another error...
Can you help me?
Thank's :)
PortekoiHi
I don't know specifically about your error, but there seems to be similar
issue with MS Query and the ODBC driver
http://groups.google.com/groups?q=SQL0107&start=0&scoring=d&hl=en&lr=&
you may want to try the oledb driver:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/his_2004Main/htm/_sna_distributed_query_support_using_the_ole_db_provider_for_db2_oledb.asp
or possibly use OPENQUERY (if you do return a rowset from the stored
procedure or add a dummy one to the query).
See also http://support.microsoft.com/kb/218590/
John
"Portekoi" <portekoi@.passion-cinquieme.com> wrote in message
news:1138975377.316513.28700@.g49g2000cwa.googlegroups.com...
> Hi,
> I have SQL Server 7 with a link server.
> When i try to execute a SP from SQL Server, i have this error :
> [ OLE/DB provider returned message: [ IBM][Pilote ODBC iSeries
> Access][DB2 UDB]SQL0107 - "pack14rexe" is too long. 10 characters
> maximum are accepted. ]
> I try this : exec recette.recette.pack14rexe.idcb050
> I think that it's the '.' but i've try to change with '/' but i have an
> another error...
> Can you help me?
> Thank's :)
>
> Portekoi
>|||I can't help you with your problem, But I sure love to know how you configured your linked server.
I am using Client Access Express and can't find any documentation for what the Product Name, Provider String
and Data Source Should be.
Thanks,
Johnny
--
---
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
---

Call Stored Procedure AS400 From SQL Server

Hi,
I have SQL Server 7 with a link server.
When i try to execute a SP from SQL Server, i have this error :
[ OLE/DB provider returned message: [ IBM][Pilote ODBC iSeries
Access][DB2 UDB]SQL0107 - "pack14rexe" is too long. 10 characters
maximum are accepted. ]
I try this : exec recette.recette.pack14rexe.idcb050
I think that it's the '.' but i've try to change with '/' but i have an
another error...
Can you help me?
Thank's
PortekoiHi
I don't know specifically about your error, but there seems to be similar
issue with MS Query and the ODBC driver
http://groups.google.com/groups?q=S...ng=d&hl=en&lr=&
you may want to try the oledb driver:
_sna_distributed_query_support_using_the
_ole_db_provider_for_db2_oledb.asp" target="_blank">http://msdn.microsoft.com/library/d...r_db2_oledb.asp
or possibly use OPENQUERY (if you do return a rowset from the stored
procedure or add a dummy one to the query).
See also http://support.microsoft.com/kb/218590/
John
"Portekoi" <portekoi@.passion-cinquieme.com> wrote in message
news:1138975377.316513.28700@.g49g2000cwa.googlegroups.com...
> Hi,
> I have SQL Server 7 with a link server.
> When i try to execute a SP from SQL Server, i have this error :
> [ OLE/DB provider returned message: [ IBM][Pilote ODBC iSerie
s
> Access][DB2 UDB]SQL0107 - "pack14rexe" is too long. 10 characters
> maximum are accepted. ]
> I try this : exec recette.recette.pack14rexe.idcb050
> I think that it's the '.' but i've try to change with '/' but i have an
> another error...
> Can you help me?
> Thank's
>
> Portekoi
>|||I can't help you with your problem, But I sure love to know how you configur
ed your linked server.
I am using Client Access Express and can't find any documentation for what t
he Product Name, Provider String
and Data Source Should be.
Thanks,
Johnny
--
---
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
---

call store procedure from another store procedure

I know I can call store procedure from store procedure but i want to take the value that the store procedure returned and to use it:

I want to create a table and to insert the result of the store procedure to it.

This is the code: Pay attention to the underlined sentence!

ALTER PROCEDURE [dbo].[test]

AS

BEGIN

SET NOCOUNT ON;

DROP TABLE tbl1

CREATE TABLE tbl1 (first_name int ,last_name nvarchar(10) )

INSERT INTO tbl1 (first_name,last_name)

VALUES (exec total_cash '8/12/2006 12:00:00 AM' '8/12/2006 12:00:00 AM' 'gilad' ,'cohen')

END

PLEASE HELP!!!! and God will repay you in kind!

Thanks!

Hi,

Use the OUTPUT parameter in your stored procedure and return this in one variable.

Regards,

|||

First, drop the "values" statement from your SQL. It should be

insert into table(col1 datatype, col2 datatype)

exec sproc 'param'

The values statement is for inserting one row at a time with specified values, if I am not mistaken.

Also, do the columns in your sproc match those in your table?

By the way, instead of dropping and recreating a table, why not truncate it:

ALTER PROCEDURE [dbo].[test]


AS

BEGIN

SET NOCOUNT ON;

TRUNCATE TABLE tbl1

INSERT INTO tbl1 (first_name,last_name)

exec total_cash '8/12/2006 12:00:00 AM' '8/12/2006 12:00:00 AM' 'gilad' ,'cohen'

END

|||

INSERT INTO tbl1 (first_name,last_name)

exec total_cash '8/12/2006 12:00:00 AM' '8/12/2006 12:00:00 AM' 'gilad' ,'cohen'

It would be great, having that supported by MSSQL, but, unfortunately, it's not so. Destination table should correspond the dataset returned by sp, except, maybe, identity columns. In some cases it is possible to use table function instead, but there are a lot of restictions.

|||

Are you saying that the statement in your email won't work? You can specify columns:

create table test
(
testId int identity,
value1 varchar(10) null,
value2 varchar(10) null,
value3 varchar(10) null
)
go
create procedure test$return
as
select '1','2'
go

insert into test (value1, value2)
exec test$return
insert into test (value2, value3)
exec test$return

go
select *
from test
go

testId value1 value2 value3
-- - - -
1 1 2 NULL
2 NULL 1 2

|||

Let's say @.res1 is output parameter and I want to save the query result in it. If i do like this, it doesn't work:

set @.re1 = SELECT SUM(dbo.InvHead.TotalToPay)

FROM dbo.InvHead INNER JOIN

dbo.StationsForUsers ON dbo.InvHead.StationNum = dbo.StationsForUsers.StationNum

WHERE ( (dbo.InvHead.invDate>= @.FromDate) AND (dbo.InvHead.invDate<= +@.ToDate) AND

(dbo.StationsForUsers.UserName =@.User_Name ))

How can I save the query result in other way?

THANKS!

|||

Hi Moria,

Try this:

SELECT @.re1 = SUM(dbo.InvHead.TotalToPay)

FROM dbo.InvHead INNER JOIN

dbo.StationsForUsers ON dbo.InvHead.StationNum = dbo.StationsForUsers.StationNum

WHERE ( (dbo.InvHead.invDate>= @.FromDate) AND (dbo.InvHead.invDate<= +@.ToDate) AND

(dbo.StationsForUsers.UserName =@.User_Name ))

Regards,

|||

He told me error:

"Incorrect syntax near the keyword 'SELECT'

anybody know why?