Deleted Values Insert into a New Table

I have Database DB and Table CB ..CB has 3 dependent Tables OB ,CP,CI
So My Requirement is ..

delete From CB
where ID_NUM not Like '99%'

But here delete will not work because of FK .. so i need to delete records from OB CP CI Tables first ...and I need to store all the Deleted Records of all the 4 Tables (CB,OB,CP,CI) in a seperate Table
May be all 4 deleted values in a Table
or
each table deleted records in each Seperate newly created table..

all i Know to go each child table and delete but ....It may be time Running Script ...
Or
Individuall for Each delete and Store in new table

More Related Resource Links

Hi all,
i have table oi want insert values into my table the data is coming from inline table valued function how i can use the inline table valued function
to insert datainto my table
i have inline function which out puts 3 collumns of data
how i can insert this data into my table
i have the insert statment like below
insert into tablename(c1,c2,c3,c4,c5)
select ('abc',....................,'xyz')
how i can use the out put put of my inline function to to insert data into my columns c2,c3,c4.
please help me out
Thanks & Regards
Sunil Yoganna

Hi everyone,
I wish to create a scenario whereby my Stored Procedure will be able to do an Insert values into two colunms but single row of a table.
For instance:
AS
BEGIN
INSERT INTO Table1 (Message1, Number1) VALUES(@Message1, @Number1)
END
When I do the above stored procedure using SQL Express, and Excecute the stored procedure in VS2005 C# using ADO.Net, the table is updated but the values of Message1 and Number1 are inserted into different rows i.e. when value is inserted into Message1,
Number1 is '0' and vice-versa.
what I really want is for both Message1 and Number1 to be inserted with values at the same row. How do I acheive this please?
Many thanks in advance.

Hi everyone,
I wish to create a scenario whereby my Stored Procedure will be able to do an Insert values into two colunms but single row of a table.
For instance:
AS
BEGIN
INSERT INTO Table1 (Message1, Number1) VALUES(@Message1, @Number1)
END
When I do the above stored procedure using SQL Express, and Excecute the stored procedure in VS2005 C# using ADO.Net, the table is updated but the values of Message1 and Number1 are inserted into different rows i.e. when value is inserted into Message1,
Number1 is '0' and vice-versa.
what I really want is for both Message1 and Number1 to be inserted with values at the same row. How do I acheive this please?
Many thanks in advance.

I have a reporting services report with a single parameter that can take up to 10 numbers which are comma delimited. I need to insert those numbers into a temp table with one column. So if the numbers were 1 - 10 I would expect to see something like this
if querying the temp table
Acct_Num
1
2
3
4
5
6
7
8
9
10
Is there a way to do this insert into the table using a comma delimeted string of numbers?
ThanksFJK

I am using CreateUserWizard control where I collect personal information from the user on the first step (ie. name, address, tel, mobile etc) then on the second step I collect information for membership service (ie. user name, password, email etc). When user clicks Create button, information is sent to two different tables in the same database. Everything works fine but one.

In the first step where I collect personal information, I also collect details about Interest which is a CheckBoxList (CheckBoxList is getting values from Interests table: 1-White, 2-Green, 3-Brown, 4-Maroon, 5-Yellow).

What I want to do is, when client selects his itnerest categories and clicks Create button, to send selected values from CheckBoxList into the third table called Categories. I want values to be registered into the CatCode column in Interests table as comma delimited. For example: if client selected "White", "Green" and "Yellow", appropriate values for those interests (such as 1, 3, 5) to be registered under Categories table CatCode column (like: 1,3,5).

--Loading the single row returned by a table valued function into a temp table works fine like this:DECLARE @techNumLoop VARCHAR(25)
DECLARE @myTemp TABLE (
Names Varchar(25)
,Item_Count Integer
,Expense_AP MONEY--,[...20 more fields]
)
--Loop a whileINSERT @myTemp SELECT * FROM ufn_FindSomeRow(@techNumLoop)
--And finally display a table with one row for each function callSELECT * FROM @myTemp
============
--My Question: what if I would like to also display the value of @techNumLoop passed in to ufn_FindSomeRow?--Then I add a field to @myTemp to hold it:DECLARE @myTemp TABLE (
TechNum VARCHAR(25)--added

* if A_date and B date are equal, one record shoould be entered to the TABLE 02. the values should be A_ID,B_ID,A_Value_B_Value and A_Date (since the date is equal, no problem; even can insert B_Date instead of A_Date)

* if A_Date and B_Date are different, then the following should happen

insert one record to TABLE02 as A_ID,B_ID, A_Value, 0 , A_Date

insert another record to TABLE02 as A_ID,B_ID, 0 , B_Value, B_Date

(As you can see, when the date differs we enter the single record of Table 01 into 2 recoerds in table 02. the Value column and Date column are related in such a way that when A's date is entered, the value for B should be 0 and vise versa..)

i tried having a UDF but in halfway remembered that we cannot include INSERTS in UDFs..

can anyone please explain me how can i solve this problem ??

PS: For your reference , i've sketched a diagram. please click on this link to view it for further clarifications

I am wondering if something can be done. I have a large database that I would like to implement change tracking on selected tables. We've come up with a way to do it the least painful way we can, but I do not know if it will work.

I've created a trigger that will pass the table name to a stored procedure. That stored procedure creates a Tracking table by appending the suffix 'Changes' to the past in table name. But now how do I get the data from the Deleted table?

I can't do a SELECT INTO or INSERT INTO because the tables have timestamp fields and blobs. I don't care if I do net get the data from those fields but I don't want to have to enter all the field names besides those two types. I can make a stored
procedure get the column names and types from a system table and dynamically build the SQL. But I would prefer to do that in one place instead of each trigger.

Basically the problem is how do I get the data from the Deleted table to another stored procedure without explicitly naming all \the fields in the trigger.

If you don't understand what I mean then please ask, I will clarify with examples.

In order to add/update/delete data from a table I build 2 classes: 1 class containing all the table fields and another class with methods to add/insert/update/delete records. I am learning how to avoid errors when your table must use SQL NULL values. One error is when I call my UPDATE method (see below):

Currently, I am working with ASP.NET MVC1 and am still learning about Model Binding and how values from a View are passed back to the Controller / Model. Specifically, I want take an existing Model, create a Table and populate the Rows of the Table, allow the user to edit some fields and pass it back.

In my example, I have a Class called "Ingredient" which has 4 public accessors: Name, Barcode, Amount, and Unit

in a crystal report , i used stored procedure name to display the fields.my problem is, in the procedure i selected the fields from two temperary tables.but in vs 2005 field explorer showing only the fields from the first temperory table.y the second temperry table fields are not displaying?

I have a table setup in the database for users who are basically going to create a classified listing. How can I setup a diagram that would easily create a table relationship with the Users table, so that it automatically inserts the users username when they submit a new ad? If so, how? I've tried adding a UserName row to my table and creating a relationship with the Users table "UserName" row, but it wasn't accepting the relationship when I tried to save the diagram...apparently because the UserName row in the Users table isn't a primary key?Also, one this is setup, what's the best way to provide the user a way to see a list of their ads and have the ability to edit them?

Hello,
I must apologize in advance because I am not sure if this is the correct place for this question. I am looking for ideas on how to build an application that in the most basic sense contains a field with the most current data from a table in a SQL Server
database
(this would be based off of a datetime timestamp in the table). I am new to this kind of problem and am unsure where to start looking for solution ideas.
The table value updates variably and could possibly update every second to every hour. I would like to design an application that would be lightweight to both the server and the user's machine. This would take the place of an unneeded report on my Reporting
Services server.
Any and all suggestions would be welcome because I am not sure of options I even have on this.
Thanks in advance for your time and consideration,
Matt