Writing Multiple Queries To A File With BCP

Jul 23, 2005

Hi

I am trying to write two Select * statements to the same text file
using bcp (from a stored procedure).

But cannot find a way of appending to a file using bcp.

Does anyone know if this is possible or is there another way of writing
multiple queries to a file from a stored procedure?

Thanks
Caro

View 2 Replies


ADVERTISEMENT

Writing Multiple SQL Tables To One Text File

Apr 7, 2008

I am trying to create a text file from multiple SQL Tables using @BCP_Command. I tried using DTS and SQL but the number of columns in the tables have to be the same size when doing a union. I also not to place a delimeter between each column. I've learned how to use BCP_commands on one file not sure if you can make it work with two or more.

Rich Pezick

View 3 Replies View Related

Writing Data From Multiple Tables To A Single Flat File

Sep 13, 2005

I have a package that contains three database tables (Header, detail and trailer record) each table is connected via a OLE DB source in SSIS. Each table varies in the amount of colums it holds and niether of the tables have the same field names. I need to transfer all data, from each table, in order, to a flat file destination.

View 6 Replies View Related

Using SQL And Writing Queries In Access

Aug 6, 2005

Hello~

I am wondering if anyone can recommend a basic, "How To" article, column or book for someone who has never worked with Access but is familiar with DB programming.

I need to know how to submit queries, and print reports.

Any help is appreciated.

Thank you!

Shelli

View 2 Replies View Related

Writing A Function Or Sub Queries

Feb 15, 2008

select atleast one record where the date different is > 5 or 10 years.
I could only figure out for 5 years. so this is what I have to do.

Select top 1 Claims# where DateDiff(yy,FromDate,ThroughDate) >5

get the CalimsId of the result and do a query on that id to select all the values of the outcome id.

how i do that.
thanks

View 14 Replies View Related

Help In Writing Queries For The Dynamic Values

Mar 18, 2008

Hello, I really have a problem writing queries for the dynamic values.  i follow the below mentioned method to write the queries but its really confusing. ex:  str = "SELECT SO.Description,SO.DiscountPct,SO.Type,SO.Category,SO.StartDate,SO.EndDate,SO.MinQty,SO.MaxQty," +                       "S.Name AS ProductSubCategory,P.Name AS ProductName, C.Name AS ProductCategory FROM Production.Product P " +                       "INNER JOIN Production.ProductSubcategory S ON P.ProductSubcategoryID = S.ProductSubcategoryID " +                       "INNER JOIN Production.ProductCategory C ON S.ProductCategoryID = C.ProductCategoryID " +                       "INNER JOIN Sales.SpecialOfferProduct SOP ON P.ProductID = SOP.ProductID " +                       "INNER JOIN Sales.SpecialOffer SO ON SOP.SpecialOfferID = SO.SpecialOfferID " +                       "WHERE '" + txtStartDate.Text + "' between SO.StartDate AND SO.EndDate AND '" + txtEndDate.Text + "' BETWEEN SO.StartDate AND SO.EndDate " +                       "AND SO.Description Like '" + txtSpecialDesc.Text + "%'";  can anybody help me in writing the queries for dynamic values in an easy way. Thank you Sandeep Chavva  

View 3 Replies View Related

Reporting Services Log File Roulette - How To Tell Which Log File SSRS Is Writing To For Errors?

Mar 13, 2007

I'm sure I'm not the only one frustrated trying to figure out which log file SSRS writes to when an error occurs. Does anybody know a sure way to tell? It doesn't change the date/time of the date modified, so you can't sort by date in windows explorer. There seems to be no rhyme or reason to which file it writes to. For example, I had to go through 6 log files to find which one was being written to. I had thought (hoped) that it would always write to the log files with the latest embedded date/time stamp as part of the file name. It does not.

I'm tempted to start using a file system spy, or resort to other tactics. Does anyone have a sure fired way to see which log file is written to when an error occurs? I'm not talking about SQL Dump files - just "normal" errors when processing reports.

Thanks,
WillyDog

View 1 Replies View Related

Writing Data To Multiple Tables (Howto)

Sep 23, 2006

Can someone show me the command string required to write data out to 2 or 3 tables at once?  How about how to write 2 entries at once?  Write now my solution writes 1 record to a table and then I write somewhere around 40-200 records to a second child .  Write now I'm writing like this:Open --> Add 1 record in table #1 --> closeOpen --> Add 1 record in table #2 --> closeOpen --> Add 1 record in table #2 --> closeOpen --> Add 1 record in table #2 --> closeOpen --> Add 1 record in table #2 --> closeand I'm just wondering if there is a better approach, such as writing all the data at once.  Something like:Open --> Add 1 record in table #1 --> Add 5 records in table #2 --> close

View 1 Replies View Related

Transact SQL :: Search Functionality With Multiple Columns - Writing SP

Jul 20, 2015

What is the most efficient way to write an SP to tackle all kinds of combinations here (where a user could give any search input).I know this must be fairly common to come across this situation.I have written an SP which will take in all the parameters and based on "IF" statements and using "LIKE" in SQL, this SP returns search results.But I wanted to know if there was more efficient ways of doing this, as you can imagine you might end up having several combinations of IF conditions.

View 9 Replies View Related

Writing Excel File Through PHP

Sep 28, 2003

I have to generate reports in Excel formats.I send the appropriate content type through header() function of PHP.But I can't get the <td> colors when using css sheets.
Following problem occurs:
1. Image doesn't come.
2.<td> does'nt take css style.
Following is the code snippet:

<?php
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=pareto_combined.xls");
?>
<link href="../../../extra/sheets/SSheet.css" rel="stylesheet" type="text/css">
<tr colspan=8>
<td height=50> <img src='../../../extra/images/log.jpg'></td>
<td align=right><img src='../../../extra/images/mickey_sup.jpg'></td>
</tr>

<?php
$dateF=$_REQUEST['dateF'];

$dateT=$_REQUEST['dateT'];

$agentID=$_REQUEST['agentID'];
?>
<tr>
<td class='graybg'><?php echo $agentID</td>
<td class='graybg'><?php echo $dateF?></td>
<td class='graybg'><?php echo $dateT?></td>
</tr>

View 1 Replies View Related

WRITING TO A FLAT FILE

Dec 18, 2007



Hi

I have a data flow task where I have to write to a flat file. It works fine for me. But the thing is next timeI run the package it must write the data in the OLDEB source to a different copy. Usually the data is overwritten or appended to already existing data. What I want is everytime the package is run the data must be written to a different copy.


Thanks

Sai Abhiram Bandhakavi

View 8 Replies View Related

Writing Txt File Into SQL Table

May 8, 2007

Hi,



My situation is:



For example i have txt file called serverlog.txt



txtfile contains:



serverid 3

Last log on 19/3/2007

Linkstatus OK



I have a table created with the following values



Table: serverlog

serverid(primarykey)

LastLogOn

LinkStatus



So my question is how do i get my txt file variables into the sql table.

Is there no import function in SQL?



Ive tried to do it with VB but thats doesnt work.



Greetings Sheila

View 23 Replies View Related

Writing XMLReader Data To A File

Nov 26, 2007

I'm trying to do this: ------------------------------------- 1) Have SQL server return some data from this simple stored procedure. It returns XML: SELECT * FROM eAccessTypes FOR XML AUTO ------------------------------------- 2) In my C# I capture the return value in an XmlReader like so: XmlReader xmlr = mySqlCommand.ExecuteXmlReader();
After this i want to write the xmlr data to a file.
Any ideas
 
 

View 2 Replies View Related

Writing Data From XML File To Database

Feb 16, 2008

Hi Guys
 In my project I need to write the data from an xml file to Database through a stored precedure.
On line a lot of help is available for writing data from Database to xml but I didnt see much info
about writing xml to database.
If any one could give me some code I will really appreciate it.(I am a newbee).
This application is developed using asp.net 1.1 and sql server 2005.
Thanks for your help in advance.
 

View 3 Replies View Related

Reading Or Writing A File To A SQL Database

Nov 22, 2004

Halo, I am a bit new to this
Please can someone help me, I would like to write a file(Any type) to a SQL database like a attached document(s) for the current record and be able to detatch the document when needed.
I use VB.NET for a ASP.NET app.
I basicly would like to attach documents to a piece of equipment may it be any kind and if the user views the equipment he will be able to detatch the documents for that piece of equipment and open it with the correct software.
PLEASE HELP!!!!!!!

View 1 Replies View Related

SQL 2012 :: Writing A Query To A File

Oct 22, 2015

I am trying to write a query to a file with a unique name and pipe "|" delimited. Problem is in 2012 the sp_cmd does not exist. I am currently using the code

set @filepat = 'C:Temp'
set @filename = 'test.txt'
set @sqlCommand = 'SQL_CMD -S (local) -E -d SqlAndMe -q "EXEC ExportData" - "' +@filepath + @filename + '" -h-1'
EXEC master..xp_cmdshell @sqlCommand

View 1 Replies View Related

Writing File From SP With Text Column

Dec 21, 2006

Hi Everyone, I´m new to this group, I´m trying to write a text filesadding content from a text column (more than 8000 characters), I foundcode how to write files and it works but i have the problem when addedthe text column to the body of the file.any idea? tip? thanks in advance! Pablo.

View 1 Replies View Related

Writing Text To A Flat File

Jul 11, 2007

I have a Foreach loop which scans a table, and gets names of a bunch of procedures, and then back in the foreach loop, they get executed. Im trying to figure out how I can create a sort of log file to say the name of the procedure that is getting executed currently and the current date time stamp onto a flat file. I havent been able to figure this out yet..anyone know how to do this? I grab the names of the storedprocedures from the table and store it in a variable and use the name from the variable to actually execute the stored procedure.

I guess in essence, the question is how do i directly write lines of 'text' (from say a variable) into a flat file.

View 6 Replies View Related

Reading And Writing To Flat File

Apr 27, 2006

I'm doing a test package which reads a flat file, makes an adjustment using the derived column task and writes to the same flat file. But, the read locks the flat file, so the write can't access it. Any ideas for a resolution?

Thanks,
Dave

View 2 Replies View Related

Problem Writing To Flat File

Dec 19, 2007



Hi,



I am writing to a flat file. When the data is written to a flat file the columns have to be tilde seperated i.e ~.

What I am doing is I am taking a destintaion text file and having all the columns as tild seperated. Is there any way I can

avoid doing this. That is I should not mention couluns in the text file.

Lastly I want the columns to have a width that is fixed.

How I can do this.

Thanks

Sai

View 3 Replies View Related

Design Advice...writing A Text File

Jul 23, 2004

I need to create a text file using information from SQL tables/views in the following format...Can anyone recommend a direction or procedure to look into, i.e, sql script, custom dts, etc. The items in parentheses identify specific portions of the text file.

(01)
101081,84423,customer ,072304,customer ,11310 Via Playa De Cortes , ,San Diego ,CA,92124,
(02) 6 ,1 , , , , ,22 ,1 ,0.00 ,160.46 ,160.46 ,0.00 , , , , , , , , ,1,1
(03)B130907540,5.41 ,1
(03)B130907550,5.41 ,1
(03)B130907560,5.41 ,1
(03)B130907570,6.04 ,1
(03)B065007550,1.72 ,2
(03)B065007560,1.72 ,6
(03)B519926530,4.66 ,13
(03)B519926550,4.66 ,12
(03)B560911200,2.14 ,1
(03)B560912500,2.14 ,1
(03)B095305750,3.65 ,1

View 5 Replies View Related

Writing To Text File From Stored Procedure

Sep 26, 2013

Want to write from a table variable to a text file from a stored procedure.Read about xp_cmdshell bcp etc. but worried because it's supposed to be a security problem and needs to be from a permanent database.Also am getting error "The EXECUTE permission was denied on the object 'xp_cmdshell'..."

1. Is xp_cmdshell a bad idea to use even if I get permissions ?
2. Can a "permanent" table be used in a stored procedure starting out fresh each time with 0 rows rather than use a table variable ?

View 2 Replies View Related

Writing To A Text File From A Database Query.

Jul 20, 2005

I need to just back one table and not all the data in the table. Is there away to have SQL save the data return from a query to some text file that Ican then use to build the table in another table on another server?I am SQL server 7Thanks,S

View 1 Replies View Related

Writing To Flat File (CSV) - Duplicate Headers

Dec 2, 2006

I'm writing to a flat file destination (CSV file) which contains 2 header rows, lets call it Col1 and Col2.

For some reason, the header rows seem to get duplicated in the output - i.e.

Col1,Col2
A,B
Col1,Col2
C,D

Is there any way to resolve this?

I don't want the file to be overwritten everytime since its used for record-keeping purposes.

Thanks

View 4 Replies View Related

Writing To Text File From Stored Procedure

Mar 29, 2006

hi

Writing to text file from table/view is done using osql,bcp etc. How do we write output of stored procedure into text file??

Thank you

View 4 Replies View Related

Problem Writing Temp File For Blobs

May 28, 2008

I got this error yesterday running an SSIS package:

"The buffer manager cannot create a file to spool a long object on the directories named in the BLOBTempStoragePath property. Either an incorrect file name was provided, or there are no permissions."

This same package was working fine on a different server, so I compared the configurations of the two boxes. It turned out that the service account that runs the package was in the Windows Administrators group on one box but not the other. I added the service account to Administrators on the box that had the problem and the problem went away.

I have looked around and have not found a list of the necessary Windows permissions that an account must have in order to run an SSIS package. This list would include write permissions to the path specified in BLOBTempStoragePath. Has anyone out there configured an account with minimal permissions to run a package that has a Data Flow?

Thanks,
Ron Rice

View 5 Replies View Related

Writing A Header Row To A Flat File Destination

Sep 18, 2006

I'm unable to figure out how to write a column header to my flat file destination. My source is a OLE DB SQL query and I need the column names as a header row in my text file destination. This seems easy but the closet I can find is hardcoding the column header row in the header property. Is this the only option?



Thanks

View 1 Replies View Related

Multiple Queries

Nov 15, 2007

Hi
I have two queries, one which takes 1 second to execute and the other which takes less that a second to execute.
I need to join them up similar to the following but when I do it take forever for them to execute.
select *
from table
where column not in (select column from table2)
It is quite complex and I have a couple of views included in the queries but it executes quickly on my dev database and when I run it on the live one it takes forever. Granted there is alot more data on the live database but the individual queries only take a second to run.
 Does anyone know why there would be such a time increase whenever I join the queries and run them on my live database?
 Any help would be appreciated.
 Thanks,
Frankie

View 4 Replies View Related

Multiple Queries In The Same Sub...

Aug 11, 2004

*************************************************************
&lt;code&gt; tags added by moderator. Please use &lt;code&gt; and
&lt;/code&gt; tags to bracket comments to make code readable.

*************************************************************

I am a beginner to this whole .net thing so my code is probablly scary, but anyway, I am looking for a way to insert records into a database and then get the last ID. I am sure there is a much better way to do this, but here is the code that I have that ins't quite working:

'SQL Insert data'
Dim Conn As SqlConnection
Dim Rdr As SqlDataReader
Dim strConn As String = AppSettings("doConnect")
Dim strSQL As String = "INSERT INTO USERS (username, password, accountNum) VALUES ('" + Email.Text.Trim() + "', '" + password.Text.Trim() + "', '" + Session("accountNum").Trim() + "')"
Conn = New SqlConnection(strConn)
Dim Cmd As New SqlCommand(strSQL, Conn)
Conn.Open()
Cmd.ExecuteNonQuery()

'SQL Get Last ID
Dim ConnGet As SqlConnection
Dim RdrGet As SqlDataReader
Dim strConnGet As String = AppSettings("doConnect")
Dim strSQLGet As String = "select MAX(id) as maxid from USERS"
ConnGet = New SqlConnection(strConn)
Dim CmdGet As New SqlCommand(strSQL, Conn)
ConnGet.Open()
If CmdGet.ExecuteScalar() <> 0 Then
RdrGet = CmdGet.ExecuteReader()
While RdrGet.Read()
Session("theID") = RdrGet("name")
End While
Else
Session("theID") = 0
End If

View 1 Replies View Related

Multiple Queries

Jul 23, 2001

Does anyone know how to count multiple columns in a SQL Query from One table and return numbers I can use the following but don't know how to join the two statements to one.

SELECT COUNT(*) AS [NUMBER OF SERVERS]
FROM DBO.OS
WHERE (OSTYPE LIKE '%SER%')

The other statement is

SELECT COUNT(*) AS [NUMBER OF WORKSTATIONS]
FROM DBO.OS
WHERE (CAPTION LIKE '%9%') OR (CAPTION LIKE '%PRO%') OR (CAPTION LIKE '%ME%')

If any one has any idea's please reply or email me directly. I would greatly appreciate it.

View 1 Replies View Related

Multiple Queries

Jul 23, 2005

I'm writing an ASP page for a project and it requires multiple queries.However, I'm trying to combine multiple SELECT statements, but can'tfigure out a way that actually works.Basically, here are the SELECT statements I want to combine:SELECT * FROM schoolrequest WHERE SLid=10SELECT SLlastName FROM academicofficeWHERE schoolrequest.SLsendToId=academicoffice.AOidSELECT SLlastName FROM academicofficeWHERE schoolrequest.SLbillToId=academicoffice.AOidSELECT SLlastName FROM academicofficeWHERE schoolrequest.SLrequestorId=academicoffice.AOidSELECT * FROM diaryentry WHERE diaryentry.DEkeyValue=10AND diaryentry.DEdeletedDate IS NULLThe academicoffice table just contains basic contact info, but needs tobe used 3 times in the query to get specific contact info for 3different contacts(SLsendToId, SLbillToId, SLrequestorId)The diaryentry table contains info entered in by students. TheDEkeyValue is actually the primary id of the schoolrequest table(SLid).Any ideas?Thanks,M

View 4 Replies View Related

Database Level Triggers In SQL 2000? File Writing?

Oct 17, 2007

Hello,
Is there any ability to do database-level triggers in SQL 2000?  I have a SQL 2000 database, and I was asked if we could create a trigger that whenever anyone touches the data in a database, to create an entry in an event log?  If not, I have a main table I can put a trigger on; however, my question is how do you write to a file in a trigger as well?
Thanks.

View 2 Replies View Related

Writing Into The FLAT FILE When Derived Column Fails

Aug 30, 2007

Flat file is the source for to load the data into a table. I am using "Derived Column Component" for the data validation.

"Derived Column Component" Fails then i am writing/redirecting the records into the Flat File using "Flat File Destination" component.

It works fine except the following the issue.

Issue:
The derived columun value (that cause an error) is not get inserted into the Flat File

Scenario:
the data comes as "000000" and tring to convert to date format
(DT_DATE)("20" + RIGHT(Check_Date,2) + "/" + SUBSTRING(Check_Date,1,LEN(Check_Date) - 4) + "/" + SUBSTRING(Check_Date,LEN(Check_Date) - 3,2))

The above expression is working fine, except the data 000000 not passed into the Flat File Destination.

Pls advise. Thank you.

View 1 Replies View Related







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