I'm using ASP.net to do a Select and I want to insert all the results into a table that is stored locally
I can put an SP local but cant put on the other DB
How would i achieve this batch insert? is it possible?
Hi can any one help me with the skeleton script (sample one)of running Bulk insert in batches........ I need to do it in batches as the input data is huge.....
The logic is I have to insert thru bcp in fact table...
After that batch execution for 50,000 thousand record.... wise.... if any of the batch failes i need to identify and have to rerun from that point onwards...... this is OLAP thing...
Hi, I am in the middle of writing a console application that acquires data from dynamic odbc connections and inserts the results into a MSSQL database. I'm currently using a datareader to generate multiple calls to a stored procedure and batch execute them by means of a simple counter; this works fine. However, I'm a little concerned that it seems to take so long to execute the sql stored procs and was wondering if anyone may know of any methods to help speed it up either on the app side or sql, or both. I had a quick word with our dba who spoke briefly about some kind of process where by the application fires the request across to the database and carries on leaving the db to queue the request or something to that effect. He ran away before I could get any sort of sense out of him. Any help greatly appreciated Thanks
How do you prevent this:"If you import a very large number of rows, dividing the data into batches can offer advantages. After each batch complete, the transaction is logged. If, for any reason, a bulk-import operation terminates before completion, only the current transaction (batch) is rolled back." How can I let the whole batch rollback, instead only the current transaction (batch) rolling back?
I'm using MS JDBC driver to connect to SQLServer 2005 and trying to perform batch insert. Here is the code i'm using:
Code Snippet
try { // Assume we have a valid con con.setAutoCommit(false);
// this is the simplified SQL for the purposes of this example StringBuffer sql = new StringBuffer(); sql.append("INSERT INTO temp_batchOpt ("); sql.append("temp)"); sql.append(" VALUES (?)");
// the correct number of insertions are made if(r != null) for(int x: r) System.out.println("inserted "+x);
SQLServerResultSet keyRS = (SQLServerResultSet)insertStatement.getGeneratedKeys(); while (keyRS.next()) { int id = keyRS.getInt(1); System.out.println("**filling id ="+id); } con.commit(); } catch (BatchUpdateException bue) { bue.printStackTrace(); } catch(SQLException sqle){ sqle.printStackTrace(); } finally { // close the connection... }
I'm getting the following exception:
Code Snippetinserted 1 inserted 1 inserted -2 inserted 1 inserted -2 inserted 1 inserted -2 inserted 1 inserted -2 inserted 1 com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be run before the generated keys are available. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getGeneratedKeys(Unknown Source) at com.x.U.m.Transformer.prefetchData(Transformer.java:285) at com.x.U.m.Transformer.init(Transformer.java:51) at com.x.U.m.XMLParse.main(XMLParse.java:215)
I can get the getGeneratedKeys() to work fine with single update (not usign batch update). Is batch + getGenerated key not supported?
I have a full backup scheduled at 12.00AM ET and have a batch import on 11.55PM(5 min before full backup) which takes 30min to complete .Will the backup cover the data which is being imported?
I want to Insert 10000 rows at a time and commit in sql server , Isthere a way to do it if the source tables have no id fields ?What would be the most efficient method?ThanksAjay
I€™m facing a SQL batch insert issue on Windows 64 bit (IA-64) platform. I€™m using €˜Column-Wise Binding€™ of parameters. The example program hosted on Microsoft site (http://msdn2.microsoft.com/en-us/library/ms709287.aspx) returns error of SQL_NEED_DATA for batch insert on Windows 64 bit platform. The same code works fine on 32 bit platform. I€™m using SQL Server 2000 as the database and tried using both native SQL server ODBC driver and Merant 5.2 ODBC drivers. Any help on this will be greatly appreciated.
I need to take a variable from a tabel in SQL Server pass to a Batch file and execute the batch file. Right now I can exec the batch file with XP_CMDSHELL but how can I pass the variable to the batch file and loop through all the variables.
I am using the following batch file to execute a script that creates a db and all its objects in the local sql express:
sqlcmd -S (local)SQLExpress -i C:CreateDB.sql
This works fine, but I'm wondering if there's an easy way to put the script in the batch file, so users don't have to worry about putting the script in the C drive. I tried getting rid of the i parameter and pasting the script from the sql file into the batch file, but it didn't work.
Hi, I want to schedule a daily job using sql server to update the info. in a sql server table. This is very new to me. Could you please forward me some helpful resources. Thanks,
QuestionsI need to batch a set of update commands. Can that be done and if so what are the possible ramfications? Can one mix / match Deletes/Inserts and Updates into a SQL command via the semi-colon in a batch set? (Is this the appropriate forum?)
WHYI am unable to use the dynamic sql building found in the dataset due to a multiple table contstraints. I have built classes that will extract the differences from two datasets and report on the updates/deletes and inserts required. Since I have multiple SQL statements, it would be nice to combine them into one statement.
Platform.Net 2C#IIS6SQL Server 2000 is the eventual target database for the generated SQL
Hey guys, I periodically have to update maybe 300 records of the same column.. However, I've been udpating each record one by one. Is there a way I can do something the following.ID Name1 john2 chris3 adam4 ben5 steveupdate table1 set name = name where id = ? but have it run through an entire set of these? Is there any way of automating that rather than having to update it manually? Do i need another table with just the id numbers and the column I want to change? or do i need a txt file?
I want to design a DTS task which will: a)copy a certain given files from one directory to another b)import the files into the tables c)upon successful import delete the files from the original directory.
I done know much about scripting and need help in figuring out steps a) and c). thanks Zoey
Can someone show me an example of the syntax required to execute multiple BCP commands within the same batch (*.bat) file?
Sorry if this is a bit of a basic question, but not being a programmer by profession, I need to plead ignorance. I've tried a few things, but I just can't seem to figure it out.
I have a problem running a batch file, now the problem is that when i run the batch file the command prompts the user for an input, but I have all the output of the bat file going into a log file. So when i run the bat file the process just sits there until i hit the 'y' key or unless i nput sumthin manually. This is a problem becuase this batch file is running on the UAT server as a job and there is no one there to input once the job is running. The commnd in the batch only requires an input once a month.
for eg if run: launch_scrt.bat and i want to put sum parameters such as 'y' or 'n' to avoid the manual input once the job is running. Any ideas?
I like to schedule set of jobs in sql server 2005 to run in a particular sequence. How do I schedule batch jobs? Each job is a set of packages. Idea is to create a job with multiple steps and each step should be a one job but there is no option for the "sql server agent jobs" when mentioning each step.
What is the best way to run a scheduled task that fires off three scripts that need to be run sequentially? I could set up three different tasks but I don't know exactly how long each will take and they are interdependent.
I have a batchjob which runs a DTS package now it calls it ok However it is running against 2 Databases on 2 servers and I get a login error even tho I am using the sa login
does anyone know of any issues relating to this Hopefully with a soloution that does not involve a lot of work
In Horacle (thanks to someone else for the apt pseudonym), I am able to run a PL/SQL script saved as a file by simply typing in @ plus the path and file name. So, if I have a script called E:CreateTable.sql, I can simply enter @CreateTable.sql from the SqlPlus command line and Oracle will attempt to run all the commands in the E:CreateTable.sql file (there may be one or more commands).
Can I do the same thing in Query Analyzer (or even osql)? If so, what is the correct syntax?
I need a small help from u all. I need a Windows batch file script which does the ftp to remote machine and "puts" a file say "data.xls" from a predefined dir say "c:uploads" and puts on the database server "d:dumps".
Hai, i would like to do Bulk update to avoid the round trip to the database. Means, In my UI im dsiplaying all the employee details who are related to one particular dept. Now i want to update the bonus to all the employees based on their category. UI changes are refelected in the Datatable(.NET). Finally the datatable changes i would like to update in the Database. how can i do that.. sample code pls. im very very new to sql
I am inserting records into a table - around 1 million records. I wantto do the insert 10000 records at a time using TRAN. My insertstatement is very simple:BEGIN TRAN T1Insert INTO TABLE A(ColA, ColB, ColC)Select B.TBLBCOLA, B.TBLBCOLB, B.TBLBCOLCFROM tbltable BWHERE blah balh...etc.COMMIT TRAN T1Any hep or link on the syntax will be helpful!ThanksSri
Hi AllThis is a belter that my little brain can't handle.Basically I have 1 SQL table that contains the following fields:Stock CodeStock DescReferenceTransaction DateQtyCost PriceBasically this table stores all the transaction lines of when a userbooks stock items into stock so that they can look at a journal ofthis goods in as and when they please.My task is that the user wants a list of all the stock items with thelast cost price that they were booked in at.So I think I have to find the last transaction date used for eachstock code and then bring this back as 1 row per stock code with theabove fields of data.How the whats-its can I do this? Is it acutally possible?Any help you can give is much appreciated.RgdsLaphan
I have a windows batch file that executes a SQL Server bcp command. Iwould like to obtain a return code if the bcp command fails. However,I cannot seem to find the return code (if any) for bcp. For example,if the bcp command is improperly formatted, or has a bad password, Iwant the batch file to return an error. Right now, my batch filesimply executes and returns success, even when the bcp command fails.Has anyone run into this before?Thanks!
I am running batch jobs(Nearly 50 queries) on Production server.It is taking nearly 5 or 6 hours(some times 10 hours also) to get the results.The problem is If I loose VPN connection I am not able to save data.I need to save the data upto the query executed before I loose VPN connection Please help me
I'm running into an odd problem. I have set a backup process on a user installation, and invoke the backup using a CMD file.
When the CMD file is executed from a DOS box, or windows GUI the SQLCMD executes, but, when the same batch file gets spawned by the AT command, the SQLCMD does not exeute.
The odd part is that I have the same exact setup on another SQL Express installation on another server and it works OK.