Redirect The Queries Output

Sep 7, 2004

Hello friends

i m using Sqlserver 2000 and i wish to know that ,
Can i redirect the output of the query into a text/xls/html file !
If possible then please help me !!!!!

Thanks

View 7 Replies


ADVERTISEMENT

Redirect The Output To A Variable

Mar 26, 2008

This is my stored procedure .It is working fine .I want to capture the output in a print statement .Can anyone help me please .

alter proc r (@id INT)

as

BEGIN

DECLARE @input VARCHAR(800)

DECLARE @c_input INT

DECLARE @i_Input INT

DECLARE @input_left VARCHAR(800)

DECLARE @delimiter CHAR(1)

select @delimiter = ','

DECLARE @in VARCHAR(800)

DECLARE @list VARCHAR(800)

declare @list2 VARCHAR(800)



SET @input = 'db2,oracle,sybase'

select @c_input = (select dbo.Fx_CharCount(@delimiter,@input))

set @c_input = @c_input + 1

while @c_input > 0

BEGIN

select @i_input = charindex(@Delimiter,@input)

if @i_input != 0

BEGIN

select @input_left = left(@input, @i_input - 1)

END

else

select @input_left = @input

select @in = '''' + @input_left + ''''

select @list = ISNULL(@list + ',', '') + @in

select @input = right(@input ,(len(@input) - @i_input))

SET @c_input = @c_input -1

if @c_input = 0 or @input = @input_left

break

end

Print @list

EXECUTE ('SELECT Label FROM systemtype WHERE Label Not IN (' + @list + ')')

END




my actual task is like this
My input is a list of values seperated by commas
now my output should be list of values not in the table joined by comma

eg : if my table consists of list of all databases like

db2
oracle,
sybase,
mssql,
mysql,



myinput would be like this db2,sybase,oracle
my output should be mssql,mysql
how to get that
?



Any suggestions

View 2 Replies View Related

Redirect The Output To A Variable

Apr 17, 2008


create procedure usp_test (@AccountID INT)asbegin
DECLARE @getAccountID CURSOR
SET @getAccountID = CURSOR FOR
SELECT Account_ID
FROM Accounts
OPEN @getAccountID
FETCH NEXT
FROM @getAccountID INTO @AccountID
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @AccountID
FETCH NEXT
FROM @getAccountID INTO @AccountID
END
CLOSE @getAccountID
DEALLOCATE @getAccountIDend i get nearly ten rows in the print statement how can i assign the output to a out variable where i get all ten rows.

View 5 Replies View Related

Redirect The Complete Row To Output

Apr 26, 2008

My requirement is something like this

I get department ,salary as input from a stored procedure .
now i have to select all the employee no's from the department table.
and based on that i have to select all the employee details from employee table whose salary is greater than given salary.

and the complete row should be passed as output parameter.


This cursor is fine

create procedure usp_proc (@dept char(10),@sal decimal (10,2),@emplist cursor varying output)
declare @empid int
DECLARE @getempid CURSOR
SET @getempid = CURSOR FOR
SELECT emp_id
FROM department where dname = @dept
OPEN @getAempid
FETCH NEXT
FROM @getempid INTO @empid
WHILE @@FETCH_STATUS = 0
BEGIN
select ename,dept,dob,doj,status,pos,sal from employee where empno = @emp_id
FETCH NEXT
FROM @getempid INTO @empid
END
CLOSE @getempid
DEALLOCATE @getempid

I am getting the complete row displayed as output .
How do i redirect the output to the declared output is my concern.

View 8 Replies View Related

Hot To Redirect Output To A Text File?

Jan 22, 2002

Hi,
I have to write a sp which takes in a input and redirect the result to a text file?
Any idea how to write it?
TIA.

View 1 Replies View Related

Redirect Output To A File In MS SQL 2000

Jun 8, 2007

Hi,

Does someone know how to spool output of a query/procedure to a file? I'm running MS SQL 2000 and will have to set up an automated job which will email this file to interested parties. Here is the procedure that I'm executing:

IF EXISTS (SELECT 1 FROM sysobjects WHERE [name] = 'sp_db_stats' AND type = 'P')
DROP PROC sp_db_stats
GO

CREATE PROCEDURE sp_db_stats

@DBName sysname = '*'
AS
DECLARE @DBStatus int,
@dbid int

DECLARE DBs CURSOR FOR
SELECT name, dbid, status
FROM master..sysdatabases
FOR READ ONLY

OPEN DBs
FETCH NEXT FROM DBs INTO @DBName, @dbid, @DBStatus
WHILE @@FETCH_STATUS = 0

BEGIN
exec master..sp_helpdb @DBName

NextDB:
FETCH NEXT FROM DBs INTO @DBName, @dbid, @DBStatus
END

CLOSE DBs
DEALLOCATE DBs

NoCursor:
RETURN

Thanks in advance!
-Alla

View 10 Replies View Related

Error Output In OLE DB Destination. How To Redirect A Row?

Nov 13, 2007



Hi,

when I'm trying to redirect a row I'm having the following error:

Error 4 Validation error. Data Flow Task: OLE DB Destination [535]: The error row disposition on "input "OLE DB Destination Input" (548)" cannot be set to redirect the row when the fast load option is turned on, and the maximum insert commit size is set to zero. PCKG_MPP.dtsx

Can somebody help me?

View 10 Replies View Related

Redirect Output Of A Stored Procedure To A Table

Feb 25, 2004

How to redirect output of a stored procedure to a table

View 3 Replies View Related

Issue With XML Source And Error Output (Redirect Row)

Mar 26, 2008

This seems like a simple task that just doesn't work. I have an XML source, and on that source, I have the Error Output configured such that the Trunctations are set to "Ignore failure", and the Errors are all set to "Redirect Row". They are then being redirected to a Row Count transformation.

To set up a test for this, I have an integer type (DT_I4 specifically) that I am populating with an alpha-numeric value. For example:

<BatchID>118a</BatchID>

However, this column prevents my XML source from loading at all, and throws the following error:

The component "XML_SRC - File" (46) failed attempting to write data to output column "BatchID" (2030) on output "Payment Error Output" (115). Input string was not in a correct format.
I checked BatchID (2030) throught the advanced properties of the XML Source, and this is defined as a Unicode text stream [DT_NTEXT] field, so I don't see why there would be a problem.

Is this a bug, or am I overlooking something?

Thanks in advance for your help.
Jerad

View 6 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

Output Of Queries To A Text File

Oct 27, 1999

Hi all,

How can get the output of a quries / stored procedures in a text file and to append the text file each time quries / stored procedures run

Thanks all

View 1 Replies View Related

SQL 2012 :: Merge Two Queries To Have Only 1 Output?

Nov 2, 2015

We have two queries that run nightly and we'd like to combine them and only have one result set instead of two. What's the best way to combine these? The only difference is the Table the information is being pulled from.

Query 1:

set nocount on
select
case
when datalength(MICRACCTNUMBER) = 4 then convert(char(20),('001 000000000000'+MICRACCTNUMBER))
when datalength(MICRACCTNUMBER) = 5 then convert(char(20),('001 00000000000'+MICRACCTNUMBER))
when datalength(MICRACCTNUMBER) = 6 then convert(char(20),('001 0000000000'+MICRACCTNUMBER))

[code].....

Again, the only difference is the Table the info is coming from...

View 3 Replies View Related

Saving Output From Multiple Queries

Sep 15, 2005

Greetings,I have what seems a simple problem....I want to save the output from the following queries in 1 file in'SQL Query Analyser', but I can only save each 'grid' separately.I have about 30 queries in total. 'Messages' tells me the number ofrows affected but I need the data.So can I save all the grids together at the same time in 1 file ?ThanksMikePRINT 'HEAT 3510'SELECT f.persfirstname AS First_Name,f.perslastname AS Last_Name,a.rsrchqnumber AS Personal_nr,b.asgtassignmentid AS Contract_nr,ISNULL(c.tishcode,'') AS TS_Id,ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,d.tpitdaydate AS Payroll_Date,c.tishactualenddate AS TS_end_dateFROM resources aINNER join assignments b ON b.asgtrsrcguid = a.rsrcguidINNER join timesheets c ON c.tishasgtguid = b.asgtguidINNER join users e ON e.userguid = a.rsrcuserguidINNER join persons f ON e.userpersguid = f.persguidLEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguidWHERE a.rsrchqnumber = 80000147and b.asgtassignmentid = 0000001234and c.tishactualenddate > '20050614'and (d.tpitdaydate > '20050614'or d.tpitdaydate IS null)order by d.tpitdaydateSELECT f.persfirstname AS First_Name,f.perslastname AS Last_Name,a.rsrchqnumber AS Personal_nr,b.asgtassignmentid AS Contract_nr,ISNULL(c.tishcode,'') AS TS_Id,c.tishactualenddate AS TS_end_date,g.thisdaydate AS TSH_dateFROM resources aINNER join assignments b ON b.asgtrsrcguid = a.rsrcguidINNER join timesheets c ON c.tishasgtguid = b.asgtguidINNER join users e ON e.userguid = a.rsrcuserguidINNER join persons f ON e.userpersguid = f.persguidINNER join timesheethistory g ON g.thistishguid = c.tishguidWHERE a.rsrchqnumber = 80000147and b.asgtassignmentid = 0000001234and c.tishactualenddate > '20050619'order by g.thisdaydatePRINT 'HEAT 3213'

View 3 Replies View Related

SQL Server 2014 :: Similar Queries Produce Different Output?

Sep 22, 2015

create table #t1 (id int)
create table #t2 (id int)

insert into #t1 values (1)
insert into #t1 values (2)
insert into #t1 values (3)

insert into #t2 values (1)
insert into #t2 values (2)

Run the below quires, you will get 2 different outputs.Second is the desired output. I cant find reason for query1

-- Query1

select * from #t1 a left join #t2 b on a.id = b.id and b.id is null

-- Query1

select * from #t1 a left join #t2 b on a.id = b.id where b.id is null

View 3 Replies View Related

Redirect Bad Rows

May 16, 2007

I have a package that works fine when taking data from Oracle and loading it into SQL Server using Ole DB source and Ole DB destination tasks.



However I have a bad record in my source now. Date value for a specific field is less than year 1753. So everytime I run with that record present in the source, the load fails when it hits that record.



Whats the best to deal with this? I tried redirecting the bad record to a file but it doesnt work as SSIS doesnt let you create error output for ole db destination task, so it can sent the record into a flat file or something else for later review.



suggestions on how to trap the bad record and redirect it to a text file? and what would the dataflow look like?



thanks

View 1 Replies View Related

Redirect URI Cannot Contain Newline Characters

Apr 25, 2005

Hi i get the above error when moving from one page to another. the following code is used. Can u help

Response.Redirect("Applicationform2.aspx?Id="+StudentID.Text+"&nam="+Name.Text+"&surNa="+ SrName.Text +"&DOB="+Ddate+ "&addr="+address.Text+"&pCode="+postal.Text+"&Cntry="+country.Text+"&email="+email.Text+"&ph="+phone.Text);

i dont understand the problem, can u help resolve the problem

View 1 Replies View Related

How To Redirect A DTS Package And Connections

Jul 20, 2005

Hi,I have a DTS package (SQL2k, sp3) that I can to execute agains a newdatabase in the same server. I don't see how to easily redirect. If youchange the connection properties and clear the transformations you have toredo them one at a time (too long).If you don't data still goes to the old database.What to do?Sd

View 1 Replies View Related

Getting Column Name On Error Redirect

Aug 2, 2006

In SSIS packages, records which do not get processed successfully can be re-directed to different destination for logging or correcting purposes. With 2 additional fields ERROR_CODE and ERROR_COLUMN appended to the dirty row values. To indicate the specific error that has occurred and on which column the error has occurred, I have certain doubts on this error reporting mechanism in SSIS packages.

The ERROR_COLUMN that is reported is not the column name but a number identifying that column uniquely. how can we at run time remap this column number to the exact column name?

Any help on this will be greatly appreciated.

Thanks,
S Suresh

View 2 Replies View Related

Redirect Data To Different Tables On The Fly

Sep 4, 2007

Are there methods to redirect incoming data to different tables on the fly in the situation when application feeds data to the table via ODBC and I'm unable to alter ODBC or application settings? Somthing on the server side?

Kind regards,
A.

View 6 Replies View Related

Is It Possible To Do A Redirect In The Custom Code?

Jun 11, 2007

Is it possible to do a redirect to an arbitrary page in by using custom code?



eg.



Public sub myRedirect()

response.redirect(http://www.microsoft.com)

End sub



/Alex

View 1 Replies View Related

Error Redirect To One File

Jul 13, 2007


Hi!

I have several lookups in my data flow task and for each of these I want to redirect error to one file (append data)
I created Flat File connection manager and first lookup goes fine with errors redirected to the file.
However, second error redirect that I am sending to the same file is failing.
Error I get is:
"[Flat File Destination 1 [14851]] Warning: The process cannot access the file because it is being used by another process.€?

So my goal is to have one central file where I would redirect all records that fail.

thanks

View 1 Replies View Related

Response.Redirect && Request.QueryString

Apr 12, 2007

I have 2 pages. ( i want to pass information from a text box to the "certificate.aspx" database query)
page 1 certsearch.aspx
this is my script i have a label, commnad button, & textbox
If txtSearchCert.Text = "" Then
lblMsg.Text = "Please enter a certificate #"
Else
Response.Redirect("certificate.aspx" & txtSearchCert.Text)
End If
 
page 2 certificate.aspx
i am not sure what goes here.this is what i am trying
Request.QueryString = (txtSearchCert.text)
This is my database query on certificate.aspx page
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imacsConn %>"
SelectCommand="SELECT * FROM [SummaryBlue] WHERE REPORTNUMBER = ?"></asp:SqlDataSource>

View 3 Replies View Related

How Can I Redirect To Another Page After The PDF Report Downloaded?

Feb 21, 2008



When I click the link to download the report in web page, it can pop up a window so that let me "open" or "save". After I open or save this (.pdf) file, I want to auto redirect to another web page. Can I do that? Here is my code:

Response.AddHeader("Content-Disposition","attachment;filename="" + getExportFilename() + """);
Response.ContentType = "application/octet-stream";
byte[] result = rs.Render(TLOWebRptFunc.GetSaveReportPath(this.Context), TLOWebRptFunc.GetReportType(this.Context), null, "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>", wparam, credentials, null, out encoding, out mineType, out wparam, out warnings, out streamIDs);
Response.BinaryWrite(result);
Response.End();

View 2 Replies View Related

Redirect Reporting Services Website

Apr 2, 2008

Occassionally we have the need to redirect the Reporting Services website so users can not access it. I have in the past disabled the Report Server application pool in IIS, but it only provides the generic "Service Unavailable" message and I end up fielding phone call all day about it. I would prefer to have it display a custom webpage that explains the service outage and when they may expect it to be available again.


So far, I have created a custom webpage name SiteMessage.html and in IIS created a new virtual directory and new website. In Reporting Services Configuration Manager, under Report Manager Virtual Directory Setting, I have changed the Website and Virtual Directory settings accordingly and received confirmation that the virtual directory was created. However, when I test the site, it still brings up the default web site.

Could somone explain how I may get the desired results listed above?

View 3 Replies View Related

Client-side Redirect Problem

Feb 14, 2006

Hi there.

I have a database mirroring session running, and both principal and mirror are working fine. But when i unplug the network cable from principal server, creating a failover scenario, the client doesn´t get redirected to the mirror.

I get an error saying: "A transport-level error has ocurred when received results from the server. The specified network name is no longer available."

 

 

connection = "Data Source=SISAD;Failover Partner=Projecto-SWS1;Initial Catalog=SIERE;Persist Security Info=True;User ID=sa;Password=testing;Connection Timeout=100";

//this method is called many times by a thread, emulating some request to the server

public static void Inserir(int codAutor)

{

SqlConnection sqlConnection = new SqlConnection(connection);

SqlCommand command = new SqlCommand("insert into Autor values(@codAutor,'test')", sqlConnection);

command.CommandType = CommandType.Text;

command.Parameters.AddWithValue("@codAutor", codAutor.ToString());

command.CommandTimeout = 200;

sqlConnection.Open();

command.ExecuteNonQuery();

sqlConnection.Close();

}

 

I think the error is because the ExecuteNonQuery() method return info about the rows affected on the server. But in this case how can i create a failover scenario with client-side redirect ?

Thanks in advance.

View 4 Replies View Related

Ole Db Transformation - Redirect Rows Problem

Nov 2, 2006

Hi, i have a OLE DB transformation that executes a stored procedure. The stored procedure RAISERROR when an error is caught. I have set the OLE DB transformation to redirect rows. But instead, the task turns red and fails. Did i do something wrong here ?

View 3 Replies View Related

SQL Client Redirect - Database Mirroring

Sep 22, 2006

Hi All,

My apologies if this question seems abit basic, but I'm a DBA by trade and programming .Net isn't my strong point ;)



I've enabled database mirroring on 3 SQL 2005 servers, a principal, a mirror and a witness.



Principal - SQL 2005 Enterprise Edition, SP1

Mirror - SQL 2005 Enterprise Edition, SP1

Witness - SQL 2005 Express, SP1



I've written some test code to test the mirroring but as soon as the connection is pulled from the principal, the client re-direct doesn't work and the program bombs. I'd be grateful fi someone could have a look at my code below and tell me if there's any schoolboy errors??



(NB, the user running the code is a sys admin on all 3 servers)



Thanks in advance.



Imports System.Data.SqlClient



Public Class Form1

Dim DCTADS As New SqlClient.SqlConnection

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

DCTADS.ConnectionString = "Network=dbmssocn; Server=STUD; Failover Partner=DBDRTEST; Database=mirrortest; Integrated Security=True"

DCTADS.Open()

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim cmd As New SqlClient.SqlCommand

cmd.CommandText = "Select fulldesc from unclproduct where internal = '20000110'"

cmd.Connection = DCTADS

Dim dr As SqlClient.SqlDataReader

dr = cmd.ExecuteReader

MsgBox(DCTADS.DataSource.ToString)

If dr.Read Then

MsgBox(dr("fulldesc").ToString)

End If

dr.Close()

End Sub

End Class

View 7 Replies View Related

Redirect Bad 'good' Data To A File

Nov 23, 2007

I have a table that among other holds volume data. I need to calculate something called Intelligent Volume based on set of rules.
After all rules were followed and I still find data that does not belong to any of the rules this data is bad and needs to be reported on (can not be discarded)
I wanted to do this is sql task (insert intel. volume) and I am using Cursor to loop through all the data and all rules.
How do I redirect this data to a file so we can report on those records?

Thanks


View 9 Replies View Related

Redirect Incoming Data To Different Tables On The Fly

Sep 4, 2007


Are there methods to redirect incoming data to different tables on the fly in the situation when application feeds data to the table via ODBC and I'm unable to alter ODBC or application settings?
Kind regards,
A.

View 2 Replies View Related

Redirect Bad Data From Flat File Source

Apr 17, 2008

Hi, all,

I have this SSIS data flow ( Flat file to sql server) that I want to add a step to redirect any "bad" data instead of fail out.

I had the red arrow hocked up to a sql new table to dump the bad data, but the flow still failed.

Here is the first error, and I knew what was wrong. A description field in that line has pipe(|) character in it, which also happen to be the column delimiter in this case.

[Flat File Source [1]] Error: Data conversion failed. The data conversion for column "Column 22" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

I knew if I fixed the data, every thing will be fine, but I just want to use this redirect feature of SSIS. Is there a place where I can turn off validation, or do something to make it work?

Thanks!

View 8 Replies View Related

Automatic Client Redirect In SQL Server 2005

Oct 12, 2005

Will this work with replication too. I see it with a mirror database, but could it work if I was keeping two copies of the database and wanted to transparently reroute the connection to a surviving server?

View 3 Replies View Related

Client Side Redirect - Database Mirroring

Sep 22, 2006

Hi All,

My apologies if this question seems abit basic, but I'm a DBA by trade and programming .Net isn't my strong point ;)



I've enabled database mirroring on 3 SQL 2005 servers, a principal, a mirror and a witness.



Principal - SQL 2005 Enterprise Edition, SP1

Mirror - SQL 2005 Enterprise Edition, SP1

Witness - SQL 2005 Express, SP1



I've written some test code to test the mirroring but as soon as the connection is pulled from the principal, the client re-direct doesn't work and the program bombs. I'd be grateful fi someone could have a look at my code below and tell me if there's any schoolboy errors??



(NB, the user running the code is a sys admin on all 3 servers)



Thanks in advance.



Imports System.Data.SqlClient



Public Class Form1

Dim DCTADS As New SqlClient.SqlConnection

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

DCTADS.ConnectionString = "Network=dbmssocn; Server=STUD; Failover Partner=DBDRTEST; Database=mirrortest; Integrated Security=True"

DCTADS.Open()

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim cmd As New SqlClient.SqlCommand

cmd.CommandText = "Select fulldesc from unclproduct where internal = '20000110'"

cmd.Connection = DCTADS

Dim dr As SqlClient.SqlDataReader

dr = cmd.ExecuteReader

MsgBox(DCTADS.DataSource.ToString)

If dr.Read Then

MsgBox(dr("fulldesc").ToString)

End If

dr.Close()

End Sub

End Class

View 1 Replies View Related

Reporting Services :: SSL Redirect For SSRS 2012?

Jun 4, 2015

how to implement a redirect in SSRS? If a user goes to [URL] I want it to redirect to [URL]

View 3 Replies View Related







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