Supress Output From Execute Of A Select

Apr 23, 1999

I have a stored procedure where in a cursor I create a dynamic select
statement. If I have a non-zero result set (check @@rowcount) I output a message. The problem is I do not know how to supress the output of the
execute of the dynamically created select statement. All I want going to
output is the message. I know ISQL has this function, and so does EM. How do I do it totally within a stored procedure.

View 2 Replies


ADVERTISEMENT

Exec(select...), How Supress The Output?

Jul 20, 2005

HiI have a dynamically constructed sql query that I want to execute, e.g.exec('select * from ' + @tablename)(1) Can I suppress the output somehow if this returns no values?(2) Can I use the result of this query in another query somehow? e.g.select(3) Can I control the size of the columns in the output somehowThanksF

View 3 Replies View Related

Execute SQL Task W/ XML Output

Apr 19, 2007

I have a stored procedure that returns XML and have defined my own "Root" element w/ "ROOT('urlset')" in the stored procedure. When I put this into my Control Flow, I have a subsequent task that takes this XML stream and writes it to a file. The issue I am running into is that SSIS is adding it's own "Root" element before my output. Is there any way of avoiding this?

View 4 Replies View Related

Using XML Output From UDF In Execute SQL Task

Feb 1, 2007

Hi,

I am trying to do the following without success;

I have a UDF which returns a string of XML data (of the data type XML)

I want to use this UDF within an Execute SQL Task to set a variable to the output of the UDF.  I then want to use the variable to pass the XML string to a XML Task to apply an XSLT to the XML.

I have set the following properties in the Execute SQL Task:

ResultSet: XML

SQLSourceType: Direct Input

SQLStatement: SELECT [dbo].[fn_GENERATE_XML](123) as rawxml

ResultName: 0

Variable Name:user::xml (where the variable is of type string)



My problem is something to do with the UDF call as if I substitute the UDF for a simple SELECT statement with a FOR XML Clause it works fine.

Any ideas where I am going wrong?

Thanks

 

 

View 1 Replies View Related

Execute A Task - How Can I See The Output At Different Stages ?

May 10, 2007

If ive got different pieces in a dataflow, how could I for example, see the output of a datasource before it gets to destination ? If im executing a task, what can i get access to from the immedate window to see the outputs at various stages ?

View 1 Replies View Related

Execute Process Task / Console Output

Oct 25, 2006

I'm just starting to find my way around SSIS, coming from SQL 2000 DTS, but I can't see a way of including a Win32 Console application's output into the logging process.

I've started playing around with SSIS Logs (OnTaskFailed etc..), but I can find no where to allow me to capture the output from a console app. In SQL 2000 DTS I could capture this by specifying an "output file" on the advanced tab of the job step definition. Is there something as straight forward as this in SSIS ?

I'd be grateful for a few pointers in the right direction.

View 4 Replies View Related

How To Execute A Stored Procedure With Output Parameter

Apr 17, 2008

Hi guys. I have a procedure with just one parameter. That's a output parameter. It's type is NVARCHAR
I think there's no problem with the procedure. Now I want to execute it. Can I declare that variable passed by parameter to the procedure ? Must I use the Execute command ?

thanks a lot.

View 3 Replies View Related

Output Assign To Parameter....from Execute Sql Task.

Feb 28, 2008

Hi all,

I'm trying to capture the OUTPUT from Execute Sql task...However when I run, the parameter didn't seem to capture the OUTPUT.

In my Sql Task, the parameter mapping:
Variable name: user::variable,
direction: OUTPUT,
Data Type: Varchar,
parameter name: 0,
parameter size: -1

connectiontype: OleDB
sourcetype: direct input
statement ELECT columnx FROM table1 WHERE (columnID=
(SELECT MAX(columnID) ASID
FROM table1 A)

I could be misunderstood on how Execute sql task work on Output.

thanks

View 5 Replies View Related

Trying To Set Output Variable To Row Count Result Of SQL Execute Task

Nov 5, 2007

I am building this as an expression, but it is not working. I am trying to return the row count into a variable to use later in an update statement. What am I doing wrong? I am using a single row result set. I have one variable defined in my result set. I am receiving an error stating: Execute SQL Task: There is an invalid number of result bindings returned for the ResultSetType: "ResultSetType_SingleRow". Any help is appreciated!

SELECT count(*) FROM hsi.itemdata a
JOIN hsi.keyitem105 b on a.itemnum = b.itemnum
JOIN hsi.keyitem106 c on a.itemnum = c.itemnum
JOIN hsi.keyitem108 d on a.itemnum = d.itemnum
WHERE a.itemtypegroupnum = 102
AND a.itemtypenum = 108
AND b.keyvaluechar = " + (DT_WSTR,2)@[User::Branch] + "
AND c.keyvaluechar = " + (DT_WSTR,2)@[User:epartment] + "
AND d.keyvaluesmall = " + (DT_WSTR,7)@[User::InvoiceNumber] + ")

View 6 Replies View Related

Execute Sql Task To Set Output Parameter Of Type Integer

Jun 1, 2006

I'm having a heckuva time with creating output parameters based on a query.

Here's what I'm doing. Every day, we copy rows from our mysql table to our sql server table. We only want to copy those rows that are new, so as to not have to recopy the entire table.

So I have a DataReader Source set to Ado.net/odbc provider that connects to the mysql db.
The destination is an OLE connection to the local sql server.

I create an Execute SQL Task.
The connection is set to the OLE connection
The type is direct input
The SQL Statement is "select max(id) from copy_table"

In Parameter Mapping, I create a user variable called maxId that is an int64. That variable is now used as the Variable Name. The Direction is Output. The Parameter Name is 0.

Whatever data type I use for the mapping does not work with the variable type. If the parameter was set to ULARGE_INTEGER, here's the error
[Execute SQL Task] Error: Executing the query "SELECT MAX(stats_id) AS max_id FROM copy_table" failed with the following error: "Type name is invalid.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

If parameter is set to LONG:
[Execute SQL Task] Error: An error occurred while assigning a value to variable "maxId": "The type of the value being assigned to variable "User::maxId" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. ".

I found that if variable and parameter were dates to use datetime for the variable and DBTIMESTAMP for the parameter.

There are an awful lot of combinations between all the possible variable types, and the possible parameter types. Does anyone know the secret combination for your typical integer?

Thanks,
Lori

View 5 Replies View Related

Execute SQL Tasks With One Input And 2 Output Variables Fails

Mar 21, 2007

I am executing a stored proc with in the Execute SQL Task using OLEDB provider. I am passing the data as

ConnectionType: OLEDB

Connection : to my database

SQLSourceType: Direct

SQL Statment : Exec mysp 'table1',OUTPUT,OUTPUT

In the parmeter mappings:

variable1--direction Output, datatype Long, Parameter name: 0

variable2--direction Output, datatype date, Parameter name: 1

The variable 1 is created as int32 and variable 2 is created as dattime.

When i execute the SQLtask, I get error:

[Execute SQL Task] Error: Executing the query "Exec mysp 'table1',OUTPUT,OUTPUT" failed with the following error: "Error converting data type nvarchar to int.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.



What am i missing. I tried changing the data types adding the input variable also as a variable in the mapping. Nothing seems to work. Any ideas please?

Anitha

View 2 Replies View Related

Integration Services :: Possible To Get Output Of Execute Task To Excel Destination

Jul 10, 2015

IS that possible to get teh output of a execute sql task to excel destination.I have query which will comapre the  data difference between two databses. It will comapre all tables in both databses and list out the difference in data by each table. I need to run this query using SSIS and need to get the output to a excel sheet...I have used the data flow task to run this query but my query is giving some error when used with data flow task. So i have used excecute sql task and need to write teh out put to a excel sheet.

View 11 Replies View Related

Execute Process Task -- Redirect Standard Output To A File, Not A Variable

May 29, 2007

I'm trying to use "findstr.exe" to extract some lines of interest from a data file, which I will later load to a table. I'd like to issue this form of a command:



findstr.exe "^SEARCHSTRING" "srcfile" > "dstfile"



I build the arguments using expressions, and both the search string and source file get correctly set. However, the ">" seems to be ignored--I can see the lines spitting out to the temporary window when I run under VS.



QUESTION: how do you redirect the output of a command run under an Execute Process Task?



View 3 Replies View Related

Supress Result 0

Jul 20, 2005

I have the following code to SUM based on one field but want to be ableto not show rows which result is 0.========================SELECT Headers.employee_id AS Employee#,SUM(CASE Headers.scan_type WHEN 'I' THEN 1 ELSE 0 END) AS SIP,SUM(CASE Headers.scan_type WHEN 'F' THEN 1 ELSE 0 END) AS PUP,SUM(CASE Headers.scan_type WHEN 'Q' THEN 1 ELSE 0 END) AS CMT,SUM(CASE Headers.scan_type WHEN 'M' THEN 1 ELSE 0 END) AS CONS,SUM(CASE Headers.scan_type WHEN '' THEN 1 ELSE 0 END) AS HIP,SUM(CASE Headers.scan_type WHEN 'U' THEN 1 ELSE 0 END) AS HOP,SUM(CASE Headers.scan_type WHEN '^' THEN 1 ELSE 0 END) AS INSTA,SUM(CASE Headers.scan_type WHEN 'L' THEN 1 ELSE 0 END) AS ONRD,SUM(CASE Headers.scan_type WHEN 'B' THEN 1 ELSE 0 END) AS POD,SUM(CASE Headers.scan_type WHEN 'G' THEN 1 ELSE 0 END) AS PUX,SUM(CASE Headers.scan_type WHEN '#' THEN 1 ELSE 0 END) AS ROP,SUM(CASE Headers.scan_type WHEN 'J' THEN 1 ELSE 0 END) AS SOP,SUM(CASE Headers.scan_type WHEN 'N' THEN 1 ELSE 0 END) AS STAT,SUM(CASE Headers.scan_type WHEN 'R' THEN 1 ELSE 0 END) AS UNCON,SUM(CASE Headers.scan_type WHEN '<' THEN 1 ELSE 0 END) ASUSPS_PSP,SUM(CASE Headers.scan_type WHEN '"' THEN 1 ELSE 0 END) AS RIP,COUNT (Scans.header_index) AS EmpTotFROM Headers INNER JOINScans ON Headers.header_index = Scans.header_indexWHERE (Scans.datetime BETWEEN '06/18/2003 00:00:00' AND'06/19/2003 23:59:00')GROUP BY Headers.employee_idORDER BY Headers.employee_id===============================Any ideas?Thanks,Manuel--Posted via http://dbforums.com

View 9 Replies View Related

How To Supress A Line ?

Oct 4, 2007

Hi !

I am working on Converting existing Crystal reports to Reporting Services. Now I have a line in Crystal reports which has a formula for supression. I dont know whats the equivalent of supress in SSRS. I have tried Visibility as hidden but then it shows empty line but not supressed line.

View 2 Replies View Related

Execute SQL Task : Input And Output Parameters In Tsql Stataments With ADO.NET Connection Type

Jan 2, 2007

Hi Everyone,

I haven't been able to successfully use the ADO.NET connection type to use both input and output parameters in an execute sql task containing just tsql statements (no stored procedure calls). I have successfully used input parameters on their own but when i combine it with output parameters it fails on the simplest of tasks.

I would really find it beneficial if you could use the flexibility of an ADO.NET connection type as the parameter marker and parameter name can be referenced anywhere throughout the sql statement in no particular order. The addition of an output parameter would really make it great!!

Thanks



 

 

View 11 Replies View Related

Help! How Do I Supress Return Results In SP

Nov 11, 2003

I'm executing this dynamic query in the middle of stored proc to get the @hrs2 value:

select @sql=('select @hrs2 = sum('+quotename(@day2)+') from #pso_view where id = ')
select @sql= @sql+cast(@num as varchar(5))

EXEC sp_executesql @sql,N'@hrs2 int OUTPUT',@hrs2 OutPut
SELECT @hrs2

That works, but then it returns a row result with every exec and that messes up my desired row return from the contaner sp for my web control databind

Any tips on how to get the varible populated via the dynamic sql w/o rows return?

THANKS!!!!!!!!

View 2 Replies View Related

Supress Blank Rows

Jan 31, 2007

How do I get a Report Table to supress blank rows from displaying ?

In Crystal Reports this option is available under Format Detail Section, supress blank section chekckbox.

View 9 Replies View Related

How Do I Supress Duplicate Data

Feb 12, 2007

Cannot find this anywhere while creating a report. Is this an option?



thanks.

View 2 Replies View Related

Can We Supress The System Error Messages ?

Oct 5, 2001

Hi

Can we supress the System error messages ?

if yes how ?

for ex. In a table I am adding a row which is voilating primary key constarint ..I do not want system message for that ..

Server: Msg 2627, Level 14, State 1, Line 0
Violation of PRIMARY KEY constraint 'PK_b'. Cannot insert duplicate key in object 'b'.
The statement has been terminated.

I can write a user defined message for this purpose but I am not able to supress system message .

The procedure I am using is

CREATE PROCEDURE add_b
@num int,@empno int, @name varchar(6)
AS
INSERT INTO B (num, empno, ds ) values (@num,@empno,@name)
-- Test the error value.
IF @@ERROR <> 0

BEGIN

-- Return 99 to the calling program to indicate failure.

RAISERROR ('Job id 1 expects the default level of 10.', 16, 1)

PRINT "An error occurred loading the new author information"

RETURN(99)

END

ELSE

BEGIN

-- Return 0 to the calling program to indicate success.

PRINT "The new author information has been loaded"

RETURN(0)

END

GO


Sujit

View 2 Replies View Related

How To Supress/hide/filter Nulls Or Nothing-s?

Dec 26, 2006

I have several columns with expressions that return Nothing under certain conditions:

Example:=(IIF( Fields!solved.Value=False,IIF( Fields!TAT3.Value >120, IIF(Fields!TAT3.Value <144,Fields!Ticket.Value,Nothing),Nothing),Nothing))

As a result, I get tons of white/empty space, because 200 values were evaluated as Nothing and only 5 values/records were actual numbers.

How can I supress this Nothing value ?

View 4 Replies View Related

SSRS - Supress Page Breaks?

Aug 24, 2007

Hello -

Does anybody know of a way to force SSRS to render a report with no page breaks at all? And better yet, to render as such but export using breaks (I know, thats asking a lot but the first part seems to be a reasonable request)

I have 1 report that renders a lot of data with no page breaks and cannot find a SINGLE property difference from the reports that do break...

Thanks in advace,

Gary

View 3 Replies View Related

How To Supress Popup Window On Export

Feb 21, 2008

Is there any way to supress the popup window on the export option so that the first thing the user see's is the open/save dialog?

Alternatively

Is there a way to make the window close when the open/save dialog appears?

Thanks
Mike

View 7 Replies View Related

Error Redirection - How To Supress File Creation?

Oct 16, 2007


Hi all!

Iīve having some issues with a package that Iīm currently building.
The package is pretty much finished and doing what itīs supposed to,
just doing some testing to ensure everything is in order.

The package is pretty basic:
Read a fixed with text file, do a lookup on destination database table,
conditional split to determine what to insert and what to update, and thatīs it!

At the source of my data flow I have the error output set to redirect all rows,
counting those rows, and finally writing them to a dynamically created file.

However, I just now realized that this file seems to be created ALWAYS,
regardless of rows actually being redirected or not. Everytime I run the package
with no rows being passed through the error output, I still end up with a
dynamically named, zero sized text file.

So my question: Is it possible to supress the creation of this file,
or do I have to add a file system component to my control flow,
deleting this file if my number of errorrows = 0 ?

Hope you can help!

Regards
Daniel

View 1 Replies View Related

Select Output

May 7, 2002

Another question for all you SQL experts, I have a lot of them. I am trying to select from a table wher some conditions need to be met based on an employee ID. What I am doing is when the rank is a 1,2, or 3 I pick up the text description of that rank. Can I make it so that I get the ID only once and all the text descriptions are on the same line. Here is the sql script along with my current output and my desired output.



--SQL SCRIPT__

select C.empID, B.Rank,B.Text1 as Skills from tbl_survey_rank B , tbl_survey_valueID C
where PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and C.empID = '2924'and
(B.Rank ='1'or B.Rank ='2' or B.Rank ='3')


--CURRENT OUTPUT--

empID Rank Skills
------- ---- --------------------------------------------------
2924 1 Create Documents
2924 2 Mail Merge
2924 3 Create Header and footer
2924 3 Create Spreadsheet
2924 3 Joining Tables in a Query



--DESIRED OUTPUT--

empID Rank Skills
------ ---- ------------
2924 1 Create Documents
2924 2 Mail Merge
2924 3 Create Header and footer, Joining Tables in a Query, Create Spreadsheet

View 1 Replies View Related

Select Output With Cursor

May 8, 2002

In my previous post I asked how to do the bottom question. I got a response to use a cursor, now I made an attempt to use a cursor but I still get the same response. Any help will be greatly appreciated.


--CURRENT OUTPUT--

empID Rank Skills
------- ---- --------------------------------------------------
2924 1 Create Documents
2924 2 Mail Merge
2924 3 Create Header and footer
2924 3 Create Spreadsheet
2924 3 Joining Tables in a Query



--DESIRED OUTPUT--

empID Rank Skills
------ ---- ------------
2924 1 Create Documents
2924 2 Mail Merge
2924 3 Create Header and footer, Joining Tables in a Query, Create Spreadsheet


--Here is the cursor script.--

Declare @skills varchar(255),@skills2 varchar(255),@message varchar(255),@empID varchar(255), @Rank varchar(255)
DECLARE emp_skills CURSOR For
select C.empID, B.Rank,B.Text1 as Skills from tbl_survey_rank B , tbl_survey_valueID C
where PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and C.empID = '2924'and
(B.Rank ='1'or B.Rank ='2' or B.Rank ='3') or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924' or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924' or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924' or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924'

DECLARE emp_skills2 CURSOR For
select B.Text1 as Skills from tbl_survey_rank B , tbl_survey_valueID C
where PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and C.empID = '2924'and
(B.Rank ='1'or B.Rank ='2' or B.Rank ='3') or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924' or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924' or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924' or PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and
B.Rank ='3'and C.empID = '2924'
OPEN emp_skills
OPEN emp_skills2
FETCH NEXT FROM emp_skills into @empID, @Rank, @skills
FETCH NEXT FROM emp_skills2 into @skills2
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @message = @skills2
FETCH NEXT FROM emp_skills2 into @skills2
Print @empID + ' '+ @Rank + ' ' + @message


FETCH NEXT FROM emp_skills into @empID, @Rank, @skills

End
CLOSE emp_skills
DEALLOCATE emp_skills
CLOSE emp_skills2
DEALLOCATE emp_skills2


--Previous Post--

Another question for all you SQL experts, I have a lot of them. I am trying to select from a table wher some conditions need to be met based on an employee ID. What I am doing is when the rank is a 1,2, or 3 I pick up the text description of that rank. Can I make it so that I get the ID only once and all the text descriptions are on the same line. Here is the sql script along with my current output and my desired output.



--SQL SCRIPT__

select C.empID, B.Rank,B.Text1 as Skills from tbl_survey_rank B , tbl_survey_valueID C
where PATINDEX ( '%'+ltrim(rtrim(B.valueID))+'%', C.text1) >0 and C.empID = '2924'and
(B.Rank ='1'or B.Rank ='2' or B.Rank ='3')


--CURRENT OUTPUT--

empID Rank Skills
------- ---- --------------------------------------------------
2924 1 Create Documents
2924 2 Mail Merge
2924 3 Create Header and footer
2924 3 Create Spreadsheet
2924 3 Joining Tables in a Query



--DESIRED OUTPUT--

empID Rank Skills
------ ---- ------------
2924 1 Create Documents
2924 2 Mail Merge
2924 3 Create Header and footer, Joining Tables in a Query, Create Spreadsheet

View 2 Replies View Related

How To Put Select Output Into Different Columns?

Oct 27, 2004

I have a table like:

ID Disc
----------------
1 BUSH
2 JOHN
1 GOLE
2 MIKE

I would like output depending on ID to put Disc into two columns. Like:

ID Disc1 Disc2
----------------------------
1 BUSH NULL
2 NULL JOHN
1 GOLE NULL
2 NULL MIKE

Any help will be appreciated. Thanks

ZYT

View 2 Replies View Related

How To Do A Select From Sp_helpdb's Output ?

Sep 25, 2005

Hi friends,
I want to select only filename column of sp_helpdb's output.But I don't know how should I do this? Other way is doing a direct select from sysfiles or sysdatabases but as you know microsoft doesn't recommand this way. Also I can select that filed in my application level but it is strange for me: Of course sql server should has a proper way to do a select from output curosr of this procedure,Doesn't it?
-Thanks in advance

View 4 Replies View Related

Changing Output Of Select

Feb 18, 2015

I have a table: it contains a list of data belonging to a name, however the field 'name' defines the source.

name |field1 |field1data |

test1 |in |123
test1 |out |345
test2 |in |123
test2 |out |456
test3 |in |123
test3 |out |456

I'm trying to get the data out of the database in a columed format, I would be quite comfortable doing this if 'in' and 'out' where there own field. The output i'm trying to get is:

name |data |data |

test1 |123 |456
test2 |123 |456
test3 |123 |456

in an ideal world i'd like to be able to have the header the name of the field data - eg

name |in |out |

test1 |123 |456
test2 |123 |456
test3 |123 |456

I can use - select name,field1data from table where field1 in ("in","out")but this returns each piece of data as a new row - eg:

name |field1data |

test1 |123
test1 |456
test2 |123
test2 |456
test3 |123
test3 |456

View 1 Replies View Related

How To Use SP's Output In The SELECT Statement

Sep 8, 2006

hi guys!it's very very simple question for you mighty sql DBAs. but very hardfor a developer like me who is very very new to MS SQL.anyways the problem is i want to use one SPs out to in the SELectstatement. here is an example :select * from sp_tables tablename like 'syscolumns'please note that this is just an example. i'm using different SP but iwant to use in the same way.if anybody has anything to say. please write to me. i would be glade toread your repliesThanks,Lucky

View 3 Replies View Related

SELECT And Execute

Apr 7, 2006

Hi:
I have to loop through some records in a table, then for each row i want to execute a procedure.
I know this can be done through Cursors, is there a way to do so just with SELECT Statement?
Thank you.

View 2 Replies View Related

What Is EXECUTE (N'SELECT .........

Feb 24, 2006

i came across one query that starts with

EXECUTE (N'SELECT .........

plz , can anyone tell me what is this N'SELECT ?
what it does?
plz help me.

View 3 Replies View Related

Output Parameters And Select Statements

Mar 17, 2004

Hi,

thanks for reading!

Here is my problem: I have a strored procedure that inserts some records

into one table and then selects some records from another table at the end.

The stored procedure takes several parameters, first one of them is marked as

OUTPUT. I'm using it to return an id of the inserted record. The procedure is called from asp.net code with first parameter set as ParameterDirection.InputOutput (tried with just Output as well). Now for the problem: if the the select statement at the end returns 0 records everything works and i my first parameter contains the @@IDENTITY value from the insert statement like it is supposed to.

If the select statement at the end returns 1 or more records my output parameter is not updated at all and contains the same value as before the procedure was run. All the records are inserted correctly.

if i try to return the @@identity as a plain select statement instead of through the parameter
i get System.DBNull.

I hope you can shed some light on this for me. Here is my stored procedure:



CREATE PROCEDURE cwSaveProductInquiry
@inquiryId int OUTPUT,
@libraryName nvarchar(500),
@contactName nvarchar(200),
@address nvarchar(100),
@city nvarchar(50),
@state nvarchar(3),
@zip nvarchar(10),
@phone nvarchar(50),
@email nvarchar(100),
@comment nvarchar(3000),
@productIds nvarchar(2000)

AS

INSERT INTO INQUIRY (LibraryName, ContactName, Address, City, State, Zip, Phone, Email, Comment) VALUES(@libraryName, @contactName, @address, @city, @state, @zip, @phone, @email,@comment)


--i tried including this statement at the end as well but that did not do the

--trick either

select @inquiryId=@@IDENTITY FROM INQUIRY





set nocount on
declare @separator_position int -- This is used to locate each separator character
declare @objectId varchar(200) -- this holds each array value as it is returned

if(@productIds is not null)
begin
while patindex('%,%' , @productIds) <> 0
begin
select @separator_position = patindex('%,%' , @productIds)
select @objectId= left(@productIds, @separator_position - 1)
INSERT INTO PRODUCT_INQUIRY_LOOKUP (ProductId,InquiryId) VALUES(@objectId, @inquiryId)
select @productIds = stuff(@productIds, 1, @separator_position, '')
end
end
set nocount off

Select Distinct Email from vPRODUCT_CONTACT WHERE ProductId in
(Select ProductId From Product_Inquiry_Lookup Where InquiryId=@inquiryId)

GO

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved