Inserting Data From A Constructed Table

Mar 10, 2007

I can do this in an old (~2003) way, but I'm trying to figure out a new (2005) way.  What I've got is an e-commerce project in which users select various products from a catalog and add them to a shopping cart.  Then they go to a checkout page which displays the current contents of the shopping cart, which are contained in a manually-constructed data table (system.data.datatable). 

On the checkout page a GridView displays the contents of the data table.  At that point they can check out via button click, which launches the following (somewhat simplified) ADO.NET code:1 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
2 'Some variables
3 Dim intCounter As Integer 'Used to count the loop
4 Dim prmQuantity As New System.Data.SqlClient.SqlParameter() 'A parameter
5 Dim prmProduct As New System.Data.SqlClient.SqlParameter() 'A parameter
6 Dim prmPrice As New System.Data.SqlClient.SqlParameter() 'A parameter
7 Dim InsertCommand As New System.Data.SqlClient.SqlCommand 'The SQL insert command
8 Dim dbConnection As New System.Data.SqlClient.SqlConnection 'The connection to the DB
9
10 'Set the parameters for the SQL statement
11 prmQuantity.ParameterName = "@Quantity"
12 prmQuantity.SqlDbType = Data.SqlDbType.Int
13 prmQuantity.Size = 18
14 prmQuantity.Direction = Data.ParameterDirection.Input
15
16 prmProduct.ParameterName = "@Product"
17 prmProduct.SqlDbType = Data.SqlDbType.VarChar
18 prmProduct.Size = 50
19 prmProduct.Direction = Data.ParameterDirection.Input
20
21 prmPrice.ParameterName = "@Price"
22 prmPrice.SqlDbType = Data.SqlDbType.Int
23 prmPrice.Size = 18
24 prmPrice.Direction = Data.ParameterDirection.Input
25
26 'Create the connection to the database using web.config
27 dbConnection.ConnectionString = ConfigurationManager.ConnectionStrings("MyDB").ConnectionString
28
29 'Various command settings
30 InsertCommand.CommandText = "INSERT INTO [Orders] ([Quantity], [Product], [OrderDate], [ItemPrice]) VALUES (@Quantity, @Product, {fn NOW()}, @Price)"
31 InsertCommand.CommandType = Data.CommandType.Text
32 InsertCommand.Connection = dbConnection
33
34 'Add the rows to the database
35 For intCounter = 0 To objDT.Rows.Count - 1
36
37 'Re-inserts the data rows from objDT
38 objDR = objDT.Rows(intCounter)
39
40 'Set param values
41 prmQuantity.Value = objDR("Quantity")
42 prmProduct.Value = objDR("Product")
43 prmPrice.Value = objDR("Price")
44
45 'Add params to insert command
46 InsertCommand.Parameters.Add(prmQuantity)
47 InsertCommand.Parameters.Add(prmProduct)
48 InsertCommand.Parameters.Add(prmPrice)
49
50 'Open connection
51 InsertCommand.Connection.Open()
52
53 'Execute the insert command
54 InsertCommand.ExecuteNonQuery()
55
56 'Close connection and clear parameters for the next loop
57 InsertCommand.Connection.Close()
58 InsertCommand.Parameters.Clear()
59
60 Next
61
62 Response.Redirect("done.aspx")
63
64 End Sub
65
What I'd like to do is see if I can instead use a simplified approach based on 2.0 controls. Specifically, I was hoping that I could use an
SqlDataSource and simply tap into its built-in Insert capabilities. So I tried this alternate procedure:
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim intCounter As Integer 'Used to count the loop
For intCounter = 0 To objDT.Rows.Count - 1
DSOrdersNew.InsertParameters("Product") = objDR("Product")
DSOrdersNew.InsertParameters("Quantity") = objDR("Quantity")
DSOrdersNew.Insert()
Next
End SubWhen I run this I get an error message saying: "Unable to cast object of type 'System.String' to type 'System.Web.UI.WebControls.Parameter'."Am I just way out in left field here? I guess I don't mind doing it the old-fashioned way, but it seems like there ought to be a way
to do this. Any suggestions would be appreciated. Thanks! 

View 2 Replies


ADVERTISEMENT

Inserting Data Into Two Tables (Getting ID From Table 1 And Inserting Into Table 2)

Oct 10, 2007

I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.
 Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)
 This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!

View 3 Replies View Related

SQL Server 2008 :: Inserting Data From Staging Table To Main Table

Feb 23, 2015

I am trying to insert bulk data into main table from staging table in sql server 2012. If any error comes, this total activity is rollbacked. I don't want that to happen. I want to know the records where ever the problem persists, and the rest has to be inserted.

View 2 Replies View Related

Inserting Distinct Data From One Table In Another Table, How?!?Really Urgent And Needing Help!!!

May 24, 2007

 Hi, I have a table in which I will insert several redundant data. Don't ask why, is Integration services, it only reads data and inserts it in a SQL table. THis way, I have a SQL table with several lines repeating them selves. What I want to do is create a procedure that reads the distinct data and inserts it in another table, but my problem is that I am not able to select data line by line on the original table to save it in local variables and insert it on the another table, I just can select the last line. I've tried a while cycle but no succeed. Here is my code: create proc insertLocalizationASdeclare @idAp int, @macAp varchar(20), @floorAp varchar(2), @building varchar(30), @department varchar(30)select @idAp = idAp from OLTPLocalization where idAp not in (select idAp from dimLocalization)select @macAp=macAp,@floorAp=floorAp,@building=building,@department=department from OLTPLocalizationif (@idAp <> null)beginInsert into dimLocalization VALUES(@idAp,@macAp,@floorAp,@building,@department)endGO This only inserts the last line in the "oltpLocalization" table. O the other hand, like this:create proc aaaaasdeclare @idAp as int, @macAp as varchar(50), @floorAp as int, @building as varchar(50), @department as varchar(50)while exists (select distinct(idAp) from OLTPLocalization)begin    select @idAp =idAp from OLTPLocalization  where idAp not in (select idAp from dimLocalization)    select @macAp = macAp from OLTPLocalization where idAp = @idAp    select @building = building from OLTPLocalization where idAp = @idAp    select @department = department from OLTPLocalization where idAP = @idApif (@idAp <> null)begin    insert into dimLocalization values(@idAp,@macAp,@floorAp,@building,@department)endendgo this retrieves every distinct idAp in each increment on the while statement. The interess of the while is really selecting each different line in the OLTPLocalization table. I did not find any foreach or for each statement, is there any way to select distinct line by line in a sql table and save each column result in variables, to then insert them in another table? I've also thought about web service, that reads the distinct data from the oltpLocalization into a dataset, and then inserts this data into the dimLocalization table. Is there anything I can do?Any guess?Really needing a hand here!Thanks a lot!

View 1 Replies View Related

Transact SQL :: Table Structure - Inserting Data From Other Temp Table

Aug 14, 2015

Below is my table structure. And I am inserting data from other temp table.

CREATE TABLE #revf (
[Cusip] [VARCHAR](50) NULL, [sponfID] [VARCHAR](max) NULL, GroupSeries [VARCHAR](max) NULL, [tran] [VARCHAR](max) NULL, [AddDate] [VARCHAR](max) NULL, [SetDate] [VARCHAR](max) NULL, [PoolNumber] [VARCHAR](max) NULL, [Aggregate] [VARCHAR](max) NULL, [Price] [VARCHAR](max) NULL, [NetAmount] [VARCHAR](max) NULL,

[Code] ....

Now in a next step I am deleting the records from #revf table. Please see the delete code below

DELETE
FROM #revf
WHERE fi_gnmaid IN (
SELECT DISTINCT r2.fi_gnmaid
FROM #revf r1, #revf r2

[Code] ...

I don't want to create this #rev table so that i can avoid the delete statement. But data should not affect. Can i rewrite the above as below:

SELECT [Cusip], [sponfID], GroupSeries, [tran], [AddDate], [SetDate], [PoolNumber], [Aggregate], [Price], [NetAmount], [Interest],
[Coupon], [TradeDate], [ReversalDate], [Description], [ImportDate], MAX([fi_gnmaid]) AS Fi_GNMAID, accounttype, [IgnoreFlag], [IgnoreReason], IncludeReversals, DatasetID, [DeloitteTaxComments], [ReconciliationID],

[Code] ....

If my above statement is wrong . Where i can improve here? And actually i am getting 4 rows difference.

View 5 Replies View Related

Inserting Data From One Table To Another

Aug 5, 2007

Hi, I have two tables in a data base and i'm inserting the data from one into the other...no probs. What i was wondering is, in table1 i have an column of ID numbers. In the table2 i have a matching set of ID numbers. There are 5 PersonID numbers in table one and 10 in table two, the same 5 numbers as in table1 but each ID has a duplicate with different data in the two rows.

SAMPLE:

INSERT
INTO Table1 (PersonID, level1, Level2, Level3, Level4)
SELECT PersonID,level1, Level2, Level3, Level4
FROM Table2

When i insert the data into table1 it leaves the first 5 rows of data as null and then populates the table with all the data from table two. Is there anyway of preventing these first 5 columns from remaining empty....

I hope that makes sense

View 3 Replies View Related

Inserting Data Into Another Table

Jan 22, 2008



Hi, I'm fairly new to SQL Server 2005.
i have a table that creates customer id's along with other data (let's call it Customer)
I would like to take the same customer_id data and import it into a different table (HQ_Customer) the new table also has different column names.

Is there a script that can be used for this problem?

View 5 Replies View Related

Inserting Data From One Table To Another

May 15, 2006

Well, I think this should be an easy question, but here goes:
I'm taking data from one table and inserting it into another. According to the SQL Server Mobile Book Online, the syntax goes like this:
INSERT INTO Table1 (col1, col2) SELECT (col1, col2) from Table2

So while I can do this with my tables:
INSERT INTO sensor_stream (sensor_stream_id) SELECT (sensor_stream_id) FROM sensor_stream_temp

If I add any more columns, I get an error. Like this:
INSERT INTO sensor_stream (sensor_stream_id, sensor_stream_type_id) SELECT (sensor_stream_id, sensor_stream_type_id) FROM sensor_stream_temp
The error is "There was an error parsing th equery. [ Token line number =1, Token line offset = 98, Token in error = ',' ]"

Anyone have any ideas about why I cannot do more than one column at a time?
TIA,
-Dana

View 4 Replies View Related

How To Create Table A By Inserting All Data From Table B?

Jan 16, 2005

Hi,

Anyone can help me?

How to create Table A by inserting all the data from Table B?

Cheers,
Daniel.

View 1 Replies View Related

Inserting Data Into A Table Referencing PK From Another Table

May 12, 2008

How do i insert data into multiple tables. Lets say i have 2 tables: Schedules and Event

Schedules data is entered into the Schedules Table first

then now i need to insert Event table's data by refrencing the (PK ID) from the schedules table.

How do i insert data into Event table referencing the (PK ID) from Schedules Table ?


Fields inside each of the tables can be found below:




Event Table
(PK,FK) ScheduleID
EventTitle
AccountManager
Presenter
EventStatus
Comment

Schedule Table
(PK) ID


AletrnateID
name
UserID
UserName
StartTime
EndTime
ReserveSource
Status
StatusRetry
NextStatusDateTime
StatusRemarks

View 2 Replies View Related

Inserting Data To Table From Textbox

Jun 17, 2008

Hello all....
I am trying to submit data from a form(textbox) to a sql table. but I am getting an error message "NullReferenceException was unhandled by user code" Can any help me with this? This is my code inProtected Sub btnSubmit_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim cnstr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()Dim pa1 As Data.SqlClient.SqlParameter = New Data.SqlClient.SqlParameter("Keyword", Data.SqlDbType.VarChar, 50, Data.ParameterDirection.Input)
pa1.Value = Keyword.Text
SqlHelper.ExecuteNonQuery(cnstr, Data.CommandType.StoredProcedure, "spNewRec", pa1)
 
Thanks in advance...

View 4 Replies View Related

Inserting Varchar Data To Table...

Jan 3, 2001

It appears that when I insert data into a varchar(8000) field, SQL Server truncates everything after the 256th byte. When I change the field to text, this problem is eliminated. Can someone give me an explanation of why? And can I actually to the insert with the field being a varchar(8000) instead of a text data type. This will do wonders for the size and indexing.

View 1 Replies View Related

Table Order When Inserting Data

Jul 23, 2005

I have to import data into a empty database, that has many tables.some tables have to be inserted first than others due to the foreignkeys.How do I find out the order of the tables that I have to insert datainto?Thanks in advance!Sam

View 6 Replies View Related

ASP.NET +Inserting Data From Xml In SQL Server Database Table From ASP.NET

May 31, 2007

hi
I want to read data from XML file and insert that data from XML file into the Database Table From ASP.NET page.plz give me the code to do this using DataAdapter.Update(ds) 

View 1 Replies View Related

Inserting Data In Batch Mode In A SQL Table Using .NET

Jun 22, 2004

Hi,

I have an ASP.NET Web Service that accepts a DataSet object passed to it. This DataSet will contain a large number of records in it's table. What I want to do (if possible) is insert all records in a SQL table in a batch mode (one go). Is this doable?

Thanks,

View 1 Replies View Related

Lock On Table While Inserting Data In Database

Jul 10, 2014

I have question on lock on table in SQL Server while inserting data using multiple processes at a single time into same table.Here are my questions on this,

1) Is it default behavior of SQL server to lock table while doing insert?
2) if yes to Q1, then how we can implicitly mention while inserting data.
3) If I have 4 tables and one table is having foreign keys from rest of the 3 tables, on this scenario do I need to use the table lock explicitly or without that I can insert records into those tables?

View 1 Replies View Related

Inserting Data Into Table - Column Does Not Allow Nulls

Sep 26, 2013

I'm inserting data from a c# webservice into a table via a stored procedure, but I get a Column does not allow nulls on the @alert_id column/field. It is set as int and allow nulls is not ticked.

Here's the sql:

USE [aren]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [aren1002].[ArenAlertInsert]

[Code] ....

View 7 Replies View Related

Transact SQL :: Inserting Distinct Data From One Table To Another

Aug 19, 2015

I have 2 tables: Source Table - IncidentDimNew and Destination Table - IncidentDimNew with identical columns: Id and CreatedDate but the data is different.

I would like to insert distinct data from those 2 columns of 1st table into the same 2 columns into the 2nd table but I onlt want to replace the values in the 2nd table where the Created Date is > 2015-04

I compiled the code in order to get the information I want from 2 tables:

Source Table
SELECT
COUNT(Id),
LEFT(CONVERT(VARCHAR(10)), CreatedDate, 126), 7)
FROM
IncidentDimNew

[Code] ...

This is the code I wrote in order to do it
                     
INSERT INTO IncidentDim 
[Id]
      ,[CreatedDate]
     SELECT
[Id]
,[CreatedDate]

FROM
IncidentDimNew

where left(CONVERT(VARCHAR(10), CreatedDate, 126),7) > '2015-04'

GO

But what it does it's gives the SUM of the values in the corresponding rows where the values are not null which I don't want.

So  how do I leave the values as is from table IncidentDim and insert new values as it is from IncidentDimNew where the Created Date is > 2015-04?

View 2 Replies View Related

Inserting Data From Access Table Into Sql Server With Vb.net

Jan 8, 2008

I am wanting to insert the data from a table in access into a table in an SQL database. I am using VB.Net 2005.

Any idea's, cheers, Darren.

View 5 Replies View Related

Inserting Data Into A Table From A String Variable

Apr 25, 2008

How to insert data into a table from a string variable? Like below:


DECLARE @Data AS NVARCHAR(MAX)

SET @Data = 'bla|bla|bla
lab|lab|lab
abl|abl|abl'


BULK INSERT tablename

FROM @Data

WITH

(


DATAFILETYPE = 'char',

FIELDTERMINATOR = '|',

ROWTERMINATOR = ''

);

View 3 Replies View Related

Inserting Data Into A Sybase Temporary Table

Aug 2, 2007

I'd like to select data out of an oracle table, and UPDATE a sybase table. So far I've got as far as the following:

1. create a package
2. add 2 connection managers, set retainsameconnection=true on both just to be sure.
3. add an executesql command which creates a temporary table


create table #temp_wm ( instru_id int)
4. add a dataflow task with:

i) an oledb source with a select statement: "select instru_id from mytable"
ii) an oledb destination with open rowset: #temp_wm
added an external column called instru_id in the inputs and outputs tab

when i run, the create temp table task work, the select works, but the insert into fails. If I change the select statement to:

"select instru_id from mytable where 1=0" it all executes fine.

So everythings copacetic as long as i don't need to actually insert any real records = brilliant!

1. HAS ANYONE OUTTHERE SUCCESSULLY USED SSIS TO INSERT DATA INTO A SYBASE TEMPORARY TALBE - MAYBE ITS JUST NOT POSSIBLE??
2. Any idea how I can fix my setup?

I'm usign Sybase ASE OLE DB Drivers

Note: i also tried ## temp tables, no difference.

This is the error output.

[OLE DB Destination [255]] Error: An OLE DB error has occurred. Error code: 0x80004005.
[OLE DB Destination [255]] Error: The "input "OLE DB Destination Input" (268)" failed because error code 0xC020907B occurred, and the error row disposition on "input "OLE DB Destination Input" (268)" specifies failure on error. An error occurred on the specified object of the specified component.
[DTS.Pipeline] Error: The ProcessInput method on component "OLE DB Destination" (255) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.



View 3 Replies View Related

DB Design :: Inserting Data From 3 Tables Into 1 Table

Jun 10, 2015

I have 3 tables (accnt, jobcost, and servic15). all with the same fields (code, jno, ven, date). I need to insert the data from these tables into another table called dummy with the same fields, in one statement or query.

View 3 Replies View Related

Inserting Data Into A Table Using A Stored Proc

Apr 17, 2008



Hi All,
I want to insert data using a stored proc. Can anyone tell me the correct syntax for inserting data into a table using a stored proc?
Thanks

View 6 Replies View Related

Inserting Data Returned From A Sproc Into A Table

Apr 12, 2006



i am writing a sproc that calls another sproc. this 2nd sproc returns 3 or 4 rows. i want to be able to insert these rows into a table. this sproc is inside a cursor, as i have to call it many times.



how do i insert the rows that it returns into another table??

View 10 Replies View Related

Inserting Data From Text File To SQL ME Table

Nov 24, 2006

Hello,

I have an application taht requires the use of a table. The device that this application works on, has a local memory that does not allow me to insert the 800,000 records that I need. Therefore I have two approaches:

1. To insert less records into my local memory database e.g 40,000 but not row by row, bulk insert is better. How do I do the bulk insert?

2. This is the most prefferable way: To find a way to insert all 800,000 records into a table on the storage card which is 1GB. What do you suggest? Will using threads be helpfull? Any ideas?

I use C# from VS 2005, SQL ME, compact framework 2.0 and windows 4.2.

Thanks in advance,

John.

View 6 Replies View Related

Sort On Field Constructed In Query

Aug 3, 2007

I want to sort on a field that I construct during a query....how can I solve this?Basically what i am doing is selecting mediafiles with comments in descending order. (so mediafile with most comments on top)Here's my (not working) query, because it throws the error that the mediaComments column is unknown....SELECT *FROM(select ROW_NUMBER() OVER (ORDER BY mediaComments DESC) as RowNum,m.title,m.usercode,mediaComments=(select count(*) from MediaComments where mediaid=m.mediaid)FROM Media m WHERE m.usercode>0group by  m.title,m.usercode) as InfoWHERE RowNum between @startRowIndex AND (@startRowIndex + @maximumRows-1)

View 4 Replies View Related

Need Help Inserting Data Into Table With Sql Insert Into Using Textbox Values

Oct 6, 2007

the error message I get is
{"Object reference not set to an instance of an object."}
and it points to <  Tickr As String = CType(FindControl("TickerTextbx"), TextBox).Text >   
 this is my code":
 Protected Sub TickMastBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TickMastBtn.Click
REM Collect variablesDim Tickr As String = CType(FindControl("TickerTextbx"), TextBox).Text
Dim Comp As String = CType(FindControl("CoTextbx"), TextBox).TextDim Exch As String = CType(FindControl("ExchTextbx"), TextBox).Text
REM Create connection and command objectsDim cn As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataVTRADE.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")Dim cmd As New SqlCommand
cmd.Connection = cn
REM Build our parameterized insert statementDim sql As New StringBuilder
sql.Append("INSERT INTO TickerMaster ")sql.Append("(Ticker,Company,Exchange,) ")sql.Append("VALUES (@Tickr,@Comp,@Exch,)")
cmd.CommandText = sql.ToString
REM Add parameter values to command
REM Parameters used to protect DB from SQL injection attacksWith cmd.Parameters
.Add("Tickr", SqlDbType.Int).Value = Tickr.Add("Comp", SqlDbType.VarChar).Value = Comp
.Add("Exch", SqlDbType.VarChar).Value = Exch
End With
REM Now execute the statement
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End Sub

View 3 Replies View Related

SQL 2012 :: Scramble Data While Inserting Onto Secondary Table

Sep 24, 2014

Do we have any way to insert,update,delete data from one table and update the changes onto second table. Also, while updating records into second table, can the data be encrypted.

I tried using view and it can insert, update, delete without any issues. But if i tried to encrypt any fields after inserting data into view, I am unable to do it.

For ex:

Table A:
EMPID LNAME FNAME
1 ABC DEF
2 DCE SKL
3 CKL DOP

Expecting output: by scrambling Lname FILED

Table B - vIEW TABLE

EMPID LNAME FNAME
1 CBD DEF
2 ECD SKL
3 LKC DOP

Tried below methods

CREATE Tableb_vw ON TableB
Instead of Insert
AS
Begin
update TableA
set Lname = (
--UserName = 'User' + substring(convert(varchar(32), UsersTrID), 1, 8)
SELECT REPLACE(LEFT(Lname, 2), '''', 'Z') AS LNAME)
FROM TableA
end

What I would like to get:

1. Can we update base tables and encrypt second table data while inserting or updating data
2. If not supported using base tables, can we do using views to encrypt view data [Some fields]

View 0 Replies View Related

SQL 2012 :: Inserting Data Into Temp Table Using 2 While Loop

Apr 21, 2015

I want to insert data (month&year) from 2014 till now - into temp table using 2 while loop.

drop table #loop
create table #loop
(
seq int identity(1,1),
[month] smallint,
[Year] smallint

For some reason I cant not get 2015 data .

View 4 Replies View Related

Default Sort Order Of The Data When Inserting From One Table To Another

May 19, 2008



I have a data load process that reads data from flat file into a Stage table in sql server. The order of the records in the stage table is exactly same as the order in the flat file. The identity column on the Stage table (which is also the clustered index) represents the exact line/row number of the data in the filat file. I perform some transformations on the data in the stage table and then insert it into a cumulative table which has a clustered index on an identity column again. When I do this, does the order of the data in the cumulative table be in the same order as the data in the stage table? Anyone, please let me know if I can rely on SQL server to maintain the same order or I will be forcing a sort order on the Identity column (clustered index) of the stage table when I insert the data into a cumulative table.


Thanks in advance!!

View 3 Replies View Related

Inserting Data In A Table From Another Table

Dec 7, 2006

I have a pb when i transfer data from a table named INCIDENT to a
table GI_INCIDENTS....
In the table INCIDENT i have startdate,enddate,starttime,endtime
And in the table GI_INCIDENTS i have startdate and enddate -->format
yyyy/MM/dd hh:mm:ss.ttt..
INCIDENT is a migrated table from access...Then with a query i
transfered datas to GI_INCIDENTS...
The pb is in INCIDENT Table, date of beginning incident is
(2003/06/18 ) but when i execute my insert query,in the table
GI_INCIDENTS, date of beginning incident is (2003/06/06)...
So i have 2 days delay in the all colums...
INCIDENT-->enddate (2006/11/30) GI_INCIDENT-->enddate(2006/11/28)
I don't understand the fact...

The query:

Insert into
GI_INCIDENTS(GIIN_ID,GIIN_STA_INCIDENT,STARTDATE,ENDDATE,GIIN_TYPE,GIIN_RESUME,GIIN_DESCRIPTION,GIIN_IMPACT_ANTENNE,GIIN_INITIATEUR)
select NUMINCIDENT,CODETAT,STARTDATE+ ' ' + STARTTIME, ENDDATE + ' '
+ ENDTIME,CODETYPE,NATURE,DESINCIDENT,CODBLOQ,NUMEXPL From INCIDENT
set IDENTITY_INSERT GI_INCIDENTS off


Thanks a lot for your help..

View 5 Replies View Related

Need Help Inserting Data In A Table That Already Has Data

Jan 4, 2006

I need to create a stored procedure that will insert data with some already exsisting data in a table. The data is in a spreadsheet, my issue is that I dont want to violate the primary key rules.

can anyone help please

CREATE PROCEDURE InsertTerms
AS
INSERT INTO [GamingCommissiondb].[dbo].[TERMINATION] ( [TM #],
[FirstName],
[LastName],
[SocialSecurityNumber],
[DateHired],
[Status],
[Title],
[DepartmentName],
[Pictures])

SELECT a.TM#, a.FirstName, a.LASTNAME, a.SSN#, a.HIREDATE, a.STATUS, a.JOBTITLE, a.DEPT#, a.PICS
FROM EmployeeGamingLicense AS a
WHERE a.STATUS = 'TERMINATED'
IF @@Error <> '0'
RETURN


GO

View 13 Replies View Related

Exporting Data From SQL Table To Excel File - How To Delete Rows Before Inserting New

Feb 5, 2007

Hi,

Question pls. I have an MS SQL local package where it exports data from SQL table to Excel file. My question is, how can erase all the records in my excel file before i export the new data from SQL table?

What i want is to delete the rows in the destination file before inserting new records.

Thanks a lot.

View 7 Replies View Related







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