.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

deleting records from multiple tables at once in SQL Sever 2005

Posted By:      Posted Date: September 25, 2010    Points: 0   Category :Sql Server

DELETE Users, meet, tour FROM Users, meet, tour WHERE Users.uid=meet.desg AND meet.desg=tour.desg AND Users.uid='CCC';

i have try this command to to delete record from three table

i want to delete all the record of uid from user ,tour and  meet at once.

Users table having a key uid which is common to all table.

 in table Users, uid is primery key

and meet table having desg and tour having desg common field value

i.e. Users.uid=meet.desg=tour.desg are same desg in both table is foreign key

so how could i delete uid from Users table ,desg from tour and meet at once and all the record from these 3 tables

View Complete Post

More Related Resource Links

Most Recent records from one of the table among the tables in multiple joins.


Hi All

I have a single select query with multiple table joins in it.

I want to retrieve the Most Recent records from one of the table among the tables in multiple joins.


(select t1.col1, t2.col2 , t3.col3, t4.col4, t4.Add_Date,t5.col5,

from dbo.table1 t1

left outer join dbo.table2 t2 on t1.col1=t2.col2

left outer join

(select col3 from dbo.table3 where condition1="expr") as t3

on t1.col1=t3.col3

left outer join dbo.table4 t4 on t1.col1=t4.col4 order by t4.Add_Date

left outer join dbo.table5 t5 on t1.col1=t5.col5 )

Problem is that, I am not able to use the "Order by" for a particular table.



how to delete records from multiple tables.


Hi Friends,Tell me How to delete records from multiple tables by using a single query.

Saving records in to multiple tables!


hi friends,

im not that familar with xml but im stumple across the problem that i cannot save 1: M relationships when i have to save more than column in the a child table. else could use csv and i could save off one column. But when i have save more than one column in ths second, third...etc i cannot think of anything else than xml.. but im familar with xmal and xpath, xquery all that.

So is there a popular atechnique that the developers use to save records into multple table than use of xml?



Cannot insert new record into multiple tables thru. sql 2005 View

I have a sql server 2005 database containing several tables: Orders, Shipping, and Planning.  They are joined together in the sql view V_Main.  I also have a ms access 2007 mdb that links to V_Main via odbc.  I created an access form using the view V_Main as the record source.  I cannot insert a new record into each of the 3 base tables using V_Main as the record source.  A new record is inserted into only one table.
I did find a suggestion in another forum that suggested copying the sql that creates the view into the record source, rather than the name of the view.  This does work, but adds another place to be updated manually should and other table be added to the view in the future.
I did verify that all tables have primary keys.
How can I add a new record for each of the 3 base tables using the view as the record source?  What is the code that could be placed in vb of the form?
Any suggestions would be helpful.
Thank you.

merging multiple tables in a single dataset to single table


 i have a stored procedure which returns three tables to a dataset ..... now i need to merge all three tables to a single table from d same dataset 

like dataset1 has table1 table2 and table3 .... i want all the three tabels to be merged into dataset1 itself .... instead of three diffrent tables so that i can show all three table data in a single datagrid  as a compact data and combination of 3 tables from d single dataset.....

can some1 help me please.....

search multiple words into textbox and populate all records in gridview related those keywords


I have a textbox and a gridview which is bound to a table

what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;

1. Book

2. Red

I have set up the sql data source and everything and my like operator is this...

LIKE '%' + @record + '%'

how can I solve this problem?

insert new records in tables from dataset to database


I have 2 tables in SqlServer 2008.

Table1: T1id, SomeData

Table2: T2id, T1id, SomeData

I am using DataAdapter.FillSchema to create shema of tables in DataSet. I created DataRelation on columns T1id in both tables.

Now when i try to Update Sql Database T1id in Table2 remains 0 and not the value of T1id in Table1.

I can successfully update Sql Database if i fill DataSet with records first (Using DataAdapter.Fill), but that's not what i want to do. I don't need "old" records in my dataset. I want to use dataset just to store all imputs from user until the proccess is done and then insert all those records "at the same time".

I think i'm getting it wrong with ForeignKeyConstraints, maybe UpdateRule is not set to cascade, i just don't know.

I have been trying to work this out for 6 days now and i'm about to break something on half.

Can someone please guide me to right direction, maybe post some sample, anything.... please!

My old post regarding this:

How to update Sql Server related tables from Dataset(SchemaFill)

SqlDataAdapter.Update related tables

Multiple XML files into SQL SERVER Express 2005

Hello. I am familiar with classic ASP and use this with MS SQL SERVER EXPRESS. I have an SQL table and want to import multiple XML files into this on a daily basis. I currently have 3 files, transferdata.vbs which loops through the XML files. FAQschema.xml which maps XML to the SQL database and test.xml shows the xml in the test file. If I run transferdata.vbs I get the following error "Error opening the data file" line 33 char 3. Microsoft Bulkload for SQL Server". My SQL table is called EnqOrd id (int), Debitor (varchar), PurchaseDate (varchar)     transferdata.vbs set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad") objBL.ConnectionString = "Provider=SQLOLEDB; Data Source=XXXXXX\XXXXX; Initial Catalog=XXXX; User ID=XXXXX; Password=XXXXXX" objBL.ErrorLogFile = "E:\fuelsql\Teccom\error.log" ' Here is the path to your XML files Const path = "E:\fuelsql\Teccom\XML\" Dim Text, Title, oFile Dim fso, oFolder, oFiles, wsh ' Object variables Text = "Folder " Title = "XML Files" Set wsh = WScript.CreateObject("WScript.Shell") ' Create FileSystemObject object to access the file system. Set fso = CreateObject("Scripting.FileSystemObject") ' Get Folder object. Set oFolder = fso.GetFolder(wsh.ExpandEnvironmentStrings(path)) ' Get All Files Set oFiles = oFolder.

SUM col from multiple tables

I am trying to SUM a column from each of 3 tables, where an ID field is the same in each table and the date range is the same also It would look something like this: table1      table2      table3      table4  amt         amt         amt         t4ID  ID           ID           ID  date        date        date SELECT SUM(t1.amt),SUM(t2.amt),SUM(t3.amt) WHERE (each table).ID = @t4ID AND (each table).date BETWEEN @date1 AND @date2 the t4ID, date1 and date2 will be chosen by the user from controls and supplied to the statement via a parameter array. I have tried many variations ( with more to go) to send 1 @t4ID parameter, for example, and use that in all 3 tables (same with the dates). Any help to nudge me in the right direction would be appreciated. Thanks

Deleting Tables...Properly

Hi, is there someone out there who can help me delete tables properly from sql server? The other day I right clicked and deleted a table from the explorer bar and now I want to name a new table the exact same name as the old one. The problem is for some reason sql sever says that the old table still exists! I'm sort of a bigtime noob in terms of operating the sql environment so...yeah. Thanks!

Generating Multiple Excel Sheet using Reporting Services 2005.

<p> Hi, I'm currently developing a program using ASP.NET 2.0 (C#) and i am using Reporting Services 2005. One of the report requirements is to export a data to an excel with multiple excel sheet. Is there other way to generate multiple excel sheet using the reporting services? if yes, i would like to ask a sample code... Thanks in advance, JP  </p> 

SSRS 2005 WebService Programatic Multiple Parameters?

I am using ssrs webservices with c#. Works great until I try to pass in multiple parameters then I get: "Default value or value provided for the report parameter 'X' is not a valid value." I am at a loss - I have the split function in my stored procedure and can pass in the values like '01/05/2010,01/062010' etc no problems. I have tried wrapping the comma seperated string with single quotes and without, tried adding them as seperate inputs with no luck same response. Report works fine from SSRS interface but not when calling it using web services. Any assistance is greatly appreciated - I have done numerous web searches and found no answers. Below is the c# code snipet: //set up the parameters List<ParameterValue> input = new List<ParameterValue>(); ParameterValue pval = new ParameterValue(); pval.Name = param.Name; pval.Value = "'" + paramsSelected + "'"; input.Add(pval); //call the report service.Render( ReportName, "PDF", null, null, input.ToArray(), null, null, out encoding, out mime, out outParams, out outWarn, out outStreams);

Delete Multiple Records

Hai friends,            How to delete multiple records using checkbox in gridview?

Select random 10 records in sql server 2005 in terms of time

Hello,i have a query that select random records in access database in terms of time : "SELECT TOP 10 * FROM Tbl ORDER BY Rnd(-10000000*TimeValue(Now())*[ID])"now i wish to convert this query for using in sql server 2005 such that return random records in term of time 

Rename a column in multiple Tables using sp_rename

Hi,Any work around for the below issue?Originally "LoadDate" column (see below scripts) was there both in tables DIM_Table_1 and DIM_Table_2According to change in requirement, LoadDate in both the tables to be chnged to LOAD_DATE. It has to be done through script-----------------EXEC sp_rename 'dbo.DIM_Table_1.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Successfully executedEXEC sp_rename 'dbo.DIM_Table_2.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Error: See below Error: The new name 'LOAD_DATE' is already in use as a COLUMN name and would cause a duplicate that is not permitted.-----------------


Hi Friends, I am creating an application for a jewellery shop (MINOR PROJECT) in VB.Net but my problem is that I dont know how to insert multiple records for same bill number. consider the following condition Bill Number Customer Name   ............................................... Customer Address ................................................ S.No                 Item name                Rate    Qty                            Total 1                      abc                            5        5                                 25 2                 &nb

How to create a SSIS package to import records form SQl Server 2008 tables to text files

I am a newbie to SSIS and would like to create a package to accomplish the task referenced in the above title. Will appreciate any links and pointers in the right direction.   Thanksakoranteng
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend