|
You cannot perform a delete on two tables at once. You can perform two deletes, and this is what you should do.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
also you could set up cascading deletes and then if you delete from one table the record gets removed from the related table. I'm never sure how much i like cascading deletes though. Pete's method is the one i would use in my code you can pass the two commands separated by ; if you only want to make 1 call (i believe)
Russ
|
|
|
|
|
You also need to be careful about the order of the delete statements if you are using foreign key constraints. In this case, you would need to delete from the address table before the contact table.
Ian
|
|
|
|
|
declare @ID as int<br />
set @ID=41 --instad 41 use parameter<br />
DELETE FROM contact WHERE ID =@ID<br />
DELETE FROM addressWHERE ID =@ID
"My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates
|
|
|
|
|
If you are using SQL Server you can write a FOR DELETE trigger on the table 'contact'. Try this: -
--------------------------------------------------------------------------------------------------
CREATE PROCEDURE DeleteContact @consultantid int
AS
DELETE FROM contact WHERE consultantid=@consultantid
--------------------------------------------------------------------------------------------------
Now create a trigger on the table 'contact': -
--------------------------------------------------------------------------------------------------
CREATE TRIGGER DeleteAddress ON contact
FOR DELETE
AS
CREATE TABLE #DeletedContacts
(
consultantid int
)
INSERT INTO #DeletedContacts SELECT consultantid FROM deleted
DELETE FROM address WHERE consultantid IN (SELECT consultantid FROM deleted)
--------------------------------------------------------------------------------------------------
Now, you execute the stored procedure: EXEC DeleteContact <anyconsultantid>
After it deletes from the table 'contact' the trigger will be excuted and it will delete corresponsing rows from the table 'address'.
I am a Software Developer using C# on ASP.NET.
|
|
|
|
|
Hy,
Backup a database with fulltext catalog doesn't work properly with a maintenance plan?
Error =>
Executing the query "BACKUP DATABASE [BD_ALA] TO DISK = N'E:\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Backup\\BD_ALA\\BD_ALA_backup_200611232301.bak' WITH NOFORMAT, NOINIT, NAME = N'BD_ALA_backup_20061123230123', SKIP, REWIND, NOUNLOAD, STATS = 10
" failed with the following error: "The backup of the file or filegroup "sysft_FullTextSlug" is not permitted because it is not online. BACKUP can be performed by using the FILEGROUP or FILE clauses to restrict the selection to include only online data.
BACKUP DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Executing the query "BACKUP DATABASE [BD_ALA] TO DISK = N'E:\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Backup\\BD_ALA\\BD_ALA_backup_200611232301.bak' WITH DIFFERENTIAL , NOFORMAT, NOINIT, NAME = N'BD_ALA_backup_20061123230139', SKIP, REWIND, NOUNLOAD, STATS = 10
" failed with the following error: "The backup of the file or filegroup "sysft_FullTextSlug" is not permitted because it is not online. BACKUP can be performed by using the FILEGROUP or FILE clauses to restrict the selection to include only online data.
BACKUP DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Executing the query "BACKUP DATABASE [BD_ALA] TO DISK = N'E:\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Backup\\BD_ALA\\BD_ALA_backup_200611232301.bak' WITH NOFORMAT, NOINIT, NAME = N'BD_ALA_backup_20061123230123', SKIP, REWIND, NOUNLOAD, STATS = 10
" failed with the following error: "The backup of the file or filegroup "sysft_FullTextSlug" is not permitted because it is not online. BACKUP can be performed by using the FILEGROUP or FILE clauses to restrict the selection to include only online data.
BACKUP DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Where I can find model's of plan maintenance for medium database (300 000 records per year) ?
Any ideas.
Best Regards
-- modified at 8:49 Friday 24th November, 2006
|
|
|
|
|
hello all,
am a begginner in sql2000 db. i want to know, how to create composite primary key in sql? using table creation wizard..can any one help me...
and also how to create triggers using sql... how to create tables and triggers using query Analyzer...please give me one simple example for create table and trigger using query analyzer.
thank you..
|
|
|
|
|
rrrriiizz wrote: i want to know, how to create composite primary key in sql? using table creation wizard..can any one help me...
I have no idea what you mean by "table creation wizard". However, in both the design view and the diagram view you can select multiple columns then right click and select "Primary Key" from the menu.
rrrriiizz wrote: and also how to create triggers using sql... how to create tables and triggers using query Analyzer...please give me one simple example for create table and trigger using query analyzer.
Have a look in the SQL server Books On Line (look up CREATE TRIGGER in the index, it will give you all the details and a few examples)
|
|
|
|
|
Hey all,
how do I update table1 depending on its relation with table2 and table3?
eg.,
UPDATE table1 SET table1.col1 = (SELECT table4.col1 FROM table4 WHERE table4.col2 = "asdfgf" ) WHERE table1.col2 = table2.col1 AND table1.col3 = table3.col1
Is the above correct?
Or should I use JOIN to do the above? If so, how do I do it?
Can anyone help?
Thanks in advance.
|
|
|
|
|
As far as my knowledge goes, I guess the above query should work as expected. A join is not needed in this case. A join is needed only when you need to combine data from multiple tables based on certain criteria.
G.Meena
|
|
|
|
|
Can anybody help ?
This is ASP.Net code
I'm trying to send Null value to stored procedure
and this can be done like this:
...
cmdInsert.Parameters.Add( "@test_var", DBNull.Value )
...
Question
How this can be done with old ASP code
If I try something like this I got error
...
Set objParam = objComm.CreateParameter("@test_var", adVarChar, adParamInput, Len(test_var), Null)
objComm.Parameters.Append objParam
...
How can I do this?
Is there in old ASP code something like "DBNull.Value" in ASP.Net
Thank u
M
|
|
|
|
|
how can i build an interface to my database
undercharm
|
|
|
|
|
undercharm wrote: how can i build an interface to my database
I think you get the prize for the most vague question of the day.
What database are you using? Is it a commerial offereing? If yes then it may already have .NET providers. Is it a database engine you created yourself? Then you will have to read up on Data Providers (The interefaces in the System.Data namespace will be a good referrence)
|
|
|
|
|
I have two database : Db1 and Db2
I want to fill tables of Db2 with some fields of Db1 tables
also I do`nt want to use from Import & Export wizard
do you have any idea
Hello Friends
|
|
|
|
|
If they're on the same server, you can prefix the owner.tablename with the database. So, suppose that you had Database1.dbo.MyTable and Database2.dbo.MyTable, you could do the following (as an example):
INSERT INTO Database2.dbo.MyTable<br />
SELECT * FROM Database1.dbo.MyTable
Obviously, you will need the relevant permissions in both dbs to do this.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
My database table consists a Field (Called ApplyDate)store the integer data, like "20061122" represent 22 nov 2006. i need to filter the data for whole November 2006, but if i write SELECT....WHERE ApplyDate = 200611 , it cannot get the data out because the last two digit no specified. So , how i write the SQL Where statement if i want to select Whole Nov 2006 ? (for example, 20061101...20061130 also acceptable)
Best regards,
Chee ken
|
|
|
|
|
why dont you use like command
example
SELECT....WHERE ApplyDate like '200611%'
this will give you proper result
|
|
|
|
|
Thanks for your reply. I also have thinking using LIKE , but if the date is 20200611(11 Jun 2020 ), then my data is getting wrong already ! aLthough the date is many years later, but i just thinking have any other way to get the correct data, any idea ? thanks.
Best regards,
Chee ken
|
|
|
|
|
"Where ApplyDate >= 20061101 and ApplyDate < 20061201"
|
|
|
|
|
I have Created a FullText Indexed table to store the Doc files.
I want querying the DocAuthor,Size, etc.. from Full Text catalog, not from OS Physical file.
I am using Sql Server 2005.
Regards
Fenil
|
|
|
|
|
please, with code and thank u another time
|
|
|
|
|
|
|
|
You're welcome.
BTW, it is customary to just replay to the same post, rather than staring a new one. That makes it much more likely that the person you are replying to will actually see the post, since replying sends an anonymous email. If you create a new psot, it may scroll off the current page long before the person you are addressing revisits that forum.
|
|
|
|