CFEXECUTE and BCP
Hi All, I have the following code example but what I need is an INSERT from a text file to a table. The following example is the reverse of what I need.
Does anyone know how ?
example for a select:
<cfset destfilename ="E:\tempdata\" & dateformat(now(),"mm-dd-yyyy") & TimeFormat(now(), "-hh-mm-ss") & ".txt">
<cfset qryStr = "select * from pubs.dbo.titles">
<cfexecute name='bcp "#qrystr#" queryout "#destfilename#" -U UserName -P Password -c'></cfexecute>
When I compare your code with the example from the BCP documentation, I come up with:
<cfset qryStr = "select * into pubs.dbo.titles2 from pubs.dbo.titles where 1=2">
<cfexecute name='bcp "#qrystr#" in "#sourceFileName#" -U UserName -P Password -c'></cfexecute>
An alternative idea:
<!--- create new, empty table to write to --->
<cfquery datasource="myDSN" name="writeToTable">
select * into pubs.dbo.titles2
from pubs.dbo.titles
where 1=2
</cfquery>
<cfexecute name='bcp "pubs.dbo.titles2" in "#sourceFileName#" -U UserName -P Password -c'></cfexecute>
Similar Messages
-
i am having a little trouble trying to get cfexecute to
create a symbolic link on linux.
i am using the below cfexecute tag to try and mimic what i am
doing from the command line, but no link is made and no output is
received from the cfexecute tag.
i have also tried /bin/ln
am i missing something?
<cfexecute name="ln" arguments="-s /home/.../filename.txt
/home/.../files/test.txt"></cfexecute>
thanks.blst02 wrote:
> i am having a little trouble trying to get cfexecute to
create a symbolic link
> on linux.
>
> i am using the below cfexecute tag to try and mimic what
i am doing from the
> command line, but no link is made and no output is
received from the cfexecute
> tag.
>
> i have also tried /bin/ln
>
> am i missing something?
>
> <cfexecute name="ln" arguments="-s
/home/.../filename.txt
> /home/.../files/test.txt"></cfexecute>
Make sure that the user CF is running as has enough rights on
the
destination directory (su to that user and try ln from that
account).
Mack -
Are there any good freeware monitoring tools available for hyperion ? Metrics I am looking to capture are Service Status, http port check, memory CPU usage etc ?
This is for 11.1.2.2 and windows 2008 R2 OS.
Also what is the best method to validate BCP ESSBASE with PROD. I am thinking taking an extract of data might help but not sure how to automate it.I don't know about free tools as EPM is a moving target, there is EM fusion middleware control which is included as part of EPM or the full version of Enterprise Manager which is not free, alternatively you can look at a product like Accelatis which is good for monitoring your EPM environment.
Cheers
John
http://john-goodwin.blogspot.com/ -
Here is my coldfusion page (gogogo.cfm):
quote:
<cfexecute name =
'c:\remotereboot.bat'></cfexecute>restarting
Here is the batch file (restartsun.bat):
quote:
shutdown /r /m \\sun /t 000
The page is on our server "Rotary" and I am trying to restart
the networked server "Sun". If I run the batch file manually it
works just fine, Sun restarts. And if I run the coldfusion page
with a different batch file, like to restart the local server, it
works just fine. But when I try to run the batch file off that
coldfusion file, it won't work.
In other words:
I want to be on my computer and call
www.website.com/gogogo.cfm (which is on the Rotary server) and have
it run restartsun.bat and restart the Sun server and it will not do
that.
Anyone have any idea?Running ColdFusion as a specific user:
http://www.adobe.com/go/tn_17279
Note that the article above is from 2006. The book
"ColdFusion 8 Web Application Construction Kit Volume 3: Advanced
Application Development" by Ben Forta includes ColdFusion 8
specific setup instructions for running the CF server as a specific
user.
http://www.forta.com/books/0321515471/ -
I am using Coldfusion8 and I am trying to implement a
spellchecker in the FCKEditor. I cannot use ASpell and the
SpellerPages option as it uses CFExecute and I cannot use that tag
on my server. Does anyone know of any other spell checker that can
be used by FCKEditor that doesn't use CFExecute?
ThanksSee here:
http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Spell_Checker
The first one listed, ieSpell, is client side and only works
on Internet Explorer, but it would suit your needs for that
purpose.
AFAIK all server-side versions require something akin to a
server-side install or use of CFExecute, neither of which a shared
host will be keen on. -
How to add specific header and footer to flat file using SSIS 2008
The SSIS package need to create file with headers, totals and adds a status to position one of the records.
Header: "$$ADD ID=ENTK0557 BID='IA HBZAC14HBZACHRYCORP' PASSWORD='CUSTOMER ' %AU HBZAC14" is added.
$$ADD = Static
ID=ENTK0557 = Static
BID='IA HBZAC14HBZACHRYCORP' = "HBZAC14" is the company, "HBZACHRYCORP" is company name
PASSWORD='CUSTOMER ' = static
HBZAC14 = company
Control Totals:
T010533343 000050 0002659604 000000 0000000000
T = Totals
010533343 = Account Number
000050 = Total records
0002659604 = Total checks
000000 = TBD
0000000000 = TBD
Data for the file
DECLARE
@T AS
TABLE
[BR-ISSUE-VOID-IND] [char]
(1)
NULL,
[BR-ACCT-NBR] [varchar]
(9)
NULL,
[FILLER1] [char]
(1)
NULL,
[BR-SERIAL-NBR] [varchar]
(8000)
NULL,
[BR-CHECK-AMT] [varchar]
(8000)
NULL,
[BR-CK-ISSUE-DATE] [varchar]
(6)
NULL
INSERT
INTO @T
[BR-ISSUE-VOID-IND]
[BR-ACCT-NBR]
[FILLER1]
[BR-SERIAL-NBR]
[BR-CHECK-AMT]
[BR-CK-ISSUE-DATE]
SELECT
'C'
,NULL,' ',30090072,2114.39,100502
UNION
ALL
SELECT
'C'
,NULL,' ',30090190,430.58,100502
UNION
ALL
SELECT
'C'
,NULL,' ',30092371,589.93,100502
UNION
ALL
SELECT
'C'
,NULL,' ',30092550,1198.6,100502
SELECT
FROM @T
File SnapShot.Using SSIS its difficult unless you use a script task after the data flow to add the header footer bits.
A much better option in this case would be bcp as you can generate query with values in the order you want and bcp it out
http://msdn.microsoft.com/en-us/library/ms162802.aspx
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
DIFFERENCE BETWEEN THE FULL AND BULK-LOGGED RECOVERY MODEL
DIFFERENCE BETWEEN THE FULL AND BULK-LOGGED RECOVERY MODEL
In bulk logged recovery mode certain bulk operations are minimally logged. In FULL recovery mode these are fully logged. These bulk operations are as mentioned below
1. SELECT INTO
2. BULK IMport operations including BULK INSERT and BCP
3. INSERT INTO SELECT command using the OPENROWSET(BULK) function
4. Partial updates to columns having large value data type
5. Using WRITE clause in UPDATE statements
6. Index operations e.g CREATE INDEX, ALTER INDEX REBUILD , DROP INDEX
In Bulk Logged Recovery Mode when you execute these operations SQL Server only logs the fact that these operation occured and information about space allocation. The actual change in the data is maintained in the BCM (Bulk
Changed Map)
Since the actual changes are not recorded in the log file, the log file size in the reletively less in size but this tradeoff comes with the price of increased backup time. This is so because during the log backup its not just the log being backup, but also
the extents that are marked by the Bulk Changed Map as changed.
SQLEnthusiast
http://sqlsimplified.com/
Please click the Mark as Answer button if a post solves your problem! -
ASE157 - Permission issue with BCP out under Solaris
With ASE15.7 SP60 on Solaris10 u11, when data is bulk copied out using Sybase’s bcp utility, the output file generated is having permissions Read/Write for the owner and Read for the group and no permissions for others even if the umask specifies different permissions.
sybase15@server:/sybdata2/backup
!> umask
0022
If I try to create a file, I get the expected file permissions:
sybase15@server:/sybdata2/backup
!> touch test
sybase15@server:/sybdata2/backup
!> ls -l test
-rw-r--r-- 1 sybase15 sybase 0 Mar 21 16:59 test
But bcpout grant different permissions:
sybase15@server:/sybdata2/backup
!> bcp db..table out /sybdata2/backup/table.bcp -Sservername -Uuser -Pxxx -c -t'(¨)' -r'(¯)\n'
Starting copy...
27 rows copied.
Clock Time (ms.): total = 16 Avg = 0 (1687.50 rows per sec.)
sybase15@server:/sybdata2/backup
!> ls -l
-rw-r----- 1 sybase15 sybase 3150 Mar 21 16:42 table.bcp
Any idea?This was a deliberate change made under CR 683458 in BCP version 15.7 ESD 4, to adopt SAP's more stringent "secure by default" policy.
A new feature has been developed that gives bcp a --filemode option that can be used to specify a less restrictive permission setting. This new feature becomes available in the connectivity 15.7 SP120 and 16.0 GA C1 releases.
Documentation: --filemode Option for isql and bcp
-bret -
UTF16 equivalent of Control A as delimiter in BCP
Hi,
I'm creating data extract using BCP which will be consumed by Hive. Hive by default understands Control A (0x01) as delimiter. When I create bcp output in -c mode and provide 0x01 as delimiter and try opening it, I can read the output file in notepad.
However when I use wide character format in bcp (-w option), and provide 0x01 as delimiter, the file shows me garbled data when I open it in notepad. Hive can not consume the data as well.
My source data has Unicode characters and so I need to use -w switch in queryout. How can I let it have Control A as delimiter? I tried with the UTF 16 equivalent (0X0001) but that does not seem to work.Hi,
The bcp utility bulk copies data between an instance of Microsoft SQL Server and a data file in a user-specified format. According to your description, you want to use bcp to export data to Hive file, In Hive file, by default Control A (0x01) can as a delimiter.
However, if you use –w performs the bulk copy operation using Unicode characters, by default,
it uses nchar as the storage type, no prefixes, \t (tab character) as the field separator, and \n (newline character) as the row terminator. If you want to change field terminator, you can use –t
switch to specify the field terminator for all the fields except the last field in the row and using the
-rswitch to specify a row terminator.
By default, I recommend you use the field terminator with character values not greater than 127 or less than 32 for avoiding character encoding problems between Hive file and bcp.
There is detail about characters supported as terminator. You can review it.
http://msdn.microsoft.com/en-us/library/ms191485.aspx
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
CFexecute, cfx_consolecommand dos/bat file error
Good day all. i have a really confussing problem... Let me
break it down
I have written an application that requires barcodes. My
Printer is a PPLB printer (not really important). So i create a
file on the server (This is about all that works fine).....
The printer is a network printer. so on the server i set up
the capture " net use LPT2
\\<machinename>\\<printersharename> /persistent:yes
(What the above does for those that do not know is set up a
vitual printer port so if you print to lpt2 it goes to the network
printer)
The command works perfectly..... Now the only thing i have to
do is send the file to the printer....
If im on the server and type "COPY /B c:\filetosend LPT2: "
note the Colon after LPT2 must be there it works perfectly.
But from anything else it doesnt..
What i have tried:
1) I tried running the command via cfexecute and
CFX_consolecommand which is available at
www.intrafoundation.com
that however does not work
2) Thinking i was smart i decided to write a bat file....
Easy. I wrote the file then used cfexecute and consolecommand to
run the file. With output enabled The error says "File Not Found"
This i have checked the file is there and LPT port is setup.
As i said if i type the command in command prompt it works
perfectly.
Now just to through another spanner in the works. if i run
the bat file from double clicking in windows or in command propt
type print.bat. (the name of the bat file i created) it works
perfectly..... Can someone explain this
So what i have determined is that:
1) When i type the command or run the bat file from command
prompt it works.
2) It does not work via cfexecute or commandconsole.
With some more testing If i leave the colon out after LPT2 it
says "0 Files Copied" so i think the colon is giving the problem...
Any help would be appreciated with this regard....
Another program maybe etc
RegardsShapeShift,
Are you running the batch file or the dos command while
logged in as the
same user ColdFusion service is configured to run under? If
ColdFusion
is running under the default "Local System" account, try
turning on the
"Allow service to interact with the desktop" checkbox on the
"Log On"
tab for the ColdFusion service, or set the service to log in
with an
account you know has permissions to the remote printer.
HTH,
Carl
ShapeShift wrote:
> Good day all. i have a really confussing problem... Let
me break it down
>
> I have written an application that requires barcodes. My
Printer is a PPLB
> printer (not really important). So i create a file on
the server (This is about
> all that works fine).....
>
> The printer is a network printer. so on the server i set
up the capture " net
> use LPT2 \\<machinename>\\<printersharename>
/persistent:yes
>
> (What the above does for those that do not know is set
up a vitual printer
> port so if you print to lpt2 it goes to the network
printer)
> The command works perfectly..... Now the only thing i
have to do is send the
> file to the printer....
>
> If im on the server and type "COPY /B c:\filetosend
LPT2: " note the Colon
> after LPT2 must be there it works perfectly.
> But from anything else it doesnt..
>
> What i have tried:
> 1) I tried running the command via cfexecute and
CFX_consolecommand which is
> available at
http://www.intrafoundation.com
that however does not work
>
> 2) Thinking i was smart i decided to write a bat
file.... Easy. I wrote the
> file then used cfexecute and consolecommand to run the
file. With output
> enabled The error says "File Not Found" This i have
checked the file is there
> and LPT port is setup.
>
> As i said if i type the command in command prompt it
works perfectly.
>
> Now just to through another spanner in the works. if i
run the bat file from
> double clicking in windows or in command propt type
print.bat. (the name of the
> bat file i created) it works perfectly..... Can someone
explain this
>
> So what i have determined is that:
> 1) When i type the command or run the bat file from
command prompt it works.
> 2) It does not work via cfexecute or commandconsole.
>
> With some more testing If i leave the colon out after
LPT2 it says "0 Files
> Copied" so i think the colon is giving the problem...
>
> Any help would be appreciated with this regard....
> Another program maybe etc
>
> Regards
>
>
> -
the icon was a very small white envelope that had a golden star and a tally of mail
it was easy to install -- only needed e-mail, not server
(I have mail through road runner)
brought up the email address so you could click and it would take you to the list, bypassing passwordI still can't get it to work that way. I changed my cfexecute to:
<cfexecute name="C:\windows\system32\cmd.exe" arguments="/c C:\Inetpub\wwwroot\captcha\#cmd_filename#" outputFile="C:\testoutput.txt" timeout = "90"></cfexecute>
And I changed my bat file to have:
<cfsavecontent variable="cmd_content">
cd\
TSC.exe /s "#newString#" C:\Inetpub\wwwroot\captcha\#FileName# Mary (for Telephone)
</cfsavecontent>
The output file is showing:
C:\ColdFusion9\runtime\bin>cd\
C:\>TSC.exe /s "3.....P.....4.....Z.....8.....U.....7.....X....." C:\Inetpub\wwwroot\captcha\3P4Z8U7X-105724.wav Mary (for Telephone)
I still can't get it to run the exe. I have watched the process list while running this and the exe doesn't show up. I tried cfexecute on the exe directly before trying the bat method, with hard coded arguments, and it still didn't work. I am so lost right now this makes no sense to me. -
ASE 16.0 installation on Linux(REDHAT 6.5)
HI All,
Below are the configuration details of my PC
processor: Intel I7
Memory: 8GB
Hard Disk: 1TB
I have installed VM ware on windows 8.1 and installed Redhat 6.5 on virtual machine.
VM mare configuration details
Memory : 2GB
hard disk: 50 GB
Download ASE from below link
http://scn.sap.com/community/developer-center/oltp-db
I have tried installing ASE 16 on RED HAT 6.5, but install failed several times, attached error message.
Error Message
Cannot run /opt/sap/OCS-16_0/bin/isql - exec failed (ENOENT)
Failed to create sample databases
Server " LOCALHOST_JSAGENT" was not created.
Failed to configure NEW JOB SCHEDULER
Kindly adviseisql is a 32-bit application. Make sure you have the 32-bit and 64-bit glibc and compat-glibc packages installed.
There is also a 64-bit version of isql (isql64) and bcp (bcp64), but I know this does not help with the initial installation.
Chris -
I'm trying to use a custom file extension for the Microsoft Access Text Driver (*.txt, *.csv) driver.
I have updated the FileExtns registry to have my new extension.
When I issue the following it does not work.
select [NoName]
from openrowset('MSDASQL'
,'Driver={Microsoft Access Text Driver (*.txt, *.csv)};
DefaultDir=c:\filedir'
,'select * from "file.lst"')
If I make the file a .csv it works fine. However, if it has an extension of not CSV or TXT (in this case .lst, which is in the registry setting) extension it throws the following error and cannot seem to find a solution to it.
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Text Driver] Cannot update. Database or object is read-only.". Msg 7350, Level 16, State 2, Line 1 Cannot get the column information from
OLE DB provider "MSDASQL" for linked server "(null)".
In addition, (although I can probably find this elsewhere), I need to have the first line 'BLANK' so that it does not miss data (there is no header row). Is there a way to use OPENROWSET without BULK to basically include all rows as data?
Any help is appreciated.Hi,
According to your description, I did a test with your script, and got the same message as your post. Usually, by default, the Microsoft Access Text Driver (*.txt, *.csv) supports the four extensions file, such as *.asc, *.csv, *.tab, *.txt. To solve this issue,
I recommend you try to save the LST file in the above format, then use OPENROESET to get data from the supported extensions file in SQL Server.
In addition, the
OPENROWSET function is mainly used to retrieve remote data from an OLEDB data source, when you use OPENROWSET without BULK, provider_name is a necessary parameter in the script. However, the OPENROWSET (BULK...) is mainly called from a SELECT…FROM clause
within an INSERT statement, when importing bulk data from a data file into SQL Server table. Thus if you need to import bulk data, you should use the basic syntax: INSERT ... SELECT * FROM OPENROWSET(BULK...), also there are some alternatives, such as
BULK INSERT
and
BCP .
Thanks
Lydia Zhang -
SQL*LOADER/SQL usage in Migration
I have very limited migration requirements. I DO NOT need to
migrate a database. I DO need to change some SQL and BCP load
scripts from SQL-SERVER 6.5 to their equivalents in ORACLE 8.0.5.
For this limited purpose, should I proceed to handcode these, or
would the workbench be of use to me?
Thanks for your help.
nullThe migration workbench does, as part of the migration,
generate the BCP and SQL*Loader files required to migrate a
database. However, since you already have the BCP files created
then the Workbench would not actually be able to just generate
the other side of the picture (the SQL*Loader files). I can
suggest the following to you :
1. Perhaps use the Workbench to run a tiny migration that would
show you how we generate the SQL*Loader scripts. It is fairly
straight forward however we need to do some manipulation on
dates.
2. There is a chapter on SQL*Loader as part of the Oracle8i
documentation set.
Chapter 3 "SQL*Loader Concepts"
Oracle8i Utilities, Release 8.1.5
A67792-01
Regards,
Marie
Raja Marla (guest) wrote:
: I have very limited migration requirements. I DO NOT need to
: migrate a database. I DO need to change some SQL and BCP
load
: scripts from SQL-SERVER 6.5 to their equivalents in ORACLE
8.0.5.
: For this limited purpose, should I proceed to handcode these,
or
: would the workbench be of use to me?
: Thanks for your help.
Oracle Technology Network
http://technet.oracle.com
null -
How to sync from a external datasource on a timed interval ?
Every 30 minutes, I want to pull data from an external data source.
I want to avoid letting the user see partial data.
The only thing I can think of is to truncate / load table A. Then do a t-sql 'merge to Table B' <-- table B is permanent data that can be accessed by users.
Is there a different approach where I don't truncate Table A?
Thanks, PeterI want to avoid letting the user see partial data.
That statement can mean many things. In addition, you only refer to a single table - and it is unusual for a database to consist of a single table so there may be aspects of your system are not obvious to the outsider. Ignoring that, the answer
to your question relies on a better understanding of "external data source" and what capabilities it supports. Obviously you don't WANT to duplicate data if you do not need to - so have you considered referencing this data directly without importing
it?
SSIS is the general tool for importing and exporting - so that is an option. Is there any particular reason behind the current implementation choice? If you need to do any significant validation or error checking or error logging, you will
find that the capabilities of plain tsql (and bcp or bulk insert) are limited. You will also need to consider what portion of data in your database is affected by this process - a real data analysis process will help you understand the scope of work
here.
Maybe you are looking for
-
How can I print all my contacts including phone numbers from iCloud
I used to be able to print all of my contacts including phone numbers etc from iCloud. Since all the upgrades I can not do this. I used to be able to change the display by clicking on a ribbon at the top then clicking the gear to have it print. No
-
Front Row Issue When iTunes is Running
On my Mac Mini (which is our media centre), I've noticed some strange behaviour. Namely, if I leave iTunes running and then start Front Row, after a while (up to 24 hours sometimes), Front Row can no longer see the iTunes library. With iTunes shutdow
-
Hello, i can't get my headphones to work right with my VIA VT1708S and therefore i try to optimize my paths config in /usr/share/pulseaudio/alsa-mixer/paths/. Thanks to the comments in analog-output.conf.common I think I already learned a lot about
-
Using a hierarchy node variable in a BI 7 web template
Hi all, I am searching for a way how to use a hierarchy node variable in a BI 7 web template. I have seen that there is a hierarchy web item, but I can only link that to a characteristic. I need to link the navigation item to a hierarchy node variabl
-
Hi all, I am after some advice on how I can use the VMware server to its maximum potential. I would like to install a training software to 10 pcs so to train people. I have to tell you that the software is quite demanding and the use of an Oracle dat