You will need to delete the reference from the foreign key table and than delete the row you want to from the primary key table.
Cheers
A....
User Profile
Collapse
-
Help On Trigger
Hi,
I am using the following trigger but it seems to do the second update and not the first update.
CREATE TRIGGER [PREPSTATUSCOMPL ETE] ON [dbo].[PrepLog]
FOR UPDATE
AS
IF EXISTS(SELECT FINISHTIME FROM PREPLOG WHERE FINISHTIME = '---')
UPDATE RMJOB
SET PSTATUS = 'PREPPING' FROM RMJOB,PREPLOG WHERE PREPLOG.FINISHT IME = '---'
AND RMJOB.RMJOBID = PREPLOG.RMJOBID
IF... -
Hi,
You need to delete the rows from the subcategories table first and then delete the corresponding rows from the categories table.
It should be pretty easy as the CategoryID should be in SubCategories table and that the field you need to use to delete rows from the subcategories table.
I hope this helps.
Aash.Leave a comment:
-
Please try the following queries:
Depending on your requirement of the output
SELECT ItemName FROM OITM WHERE
ItemName LIKE 'Twinkle%'
SELECT ItemName FROM OITM WHERE
ItemName LIKE '%English 1–4'
Aash.Leave a comment:
-
You can try the IMPORT/EXPORT Wizard which is quite easy to use.
Aash.Leave a comment:
-
Trigger Help
Hi,
I am using the following trigger but it seems to do the second update and not the first update.
CREATE TRIGGER [PREPSTATUSCOMPL ETE] ON [dbo].[PrepLog]
FOR UPDATE
AS
IF EXISTS(SELECT FINISHTIME FROM PREPLOG WHERE FINISHTIME = '---')
UPDATE RMJOB
SET PSTATUS = 'PREPPING' FROM RMJOB,PREPLOG WHERE PREPLOG.FINISHT IME = '---'
AND RMJOB.RMJOBID = PREPLOG.RMJOBID
... -
Please find below the code to find the last inserted record:
CREATE PROCEDURE name
(
@ID int OUTPUT
)
AS
INSERT INTO Table1
(DateCreated)
VALUES
( GETDATE() )
SET @ID = SCOPE_IDENTITY( )
;...Leave a comment:
-
The query is simple:
UPDATE TABLENAME
SET NEWCOLUMN = SOURCECOLUMN WHERE SOURCECOLUMN IS NOT NULL.
Thanks....Leave a comment:
-
Thanks a lot mate. I will try this later and let you know the results. sounds ok....Leave a comment:
-
The stored procedures is as follows
CREATE PROCEDURE TEST
@field1 nvarchar(50),
@field2 numeric(10)
AS
BEGIN
INSERT INTO TABLE1 (field1,field2) VALUES (@field1,@field 2)
END
Hope this helps.
Thanks,...Leave a comment:
-
Hi,
I assume you want the last insert record ( primary key) ?
Let me know and I will help you with the code?
Cheers....Leave a comment:
-
Thanks for the help
How can I get the transaction to fail so that I know it works by putting it into transaction.
Thanks...Leave a comment:
-
If Statement
Hi,
I am using the following if statment in my sql code. The problem i have is that the update statment runs successfully irregardless of wether my insert statment is successfull or not. What I need to do is if the insert is successfull run the update statement and if the insert fails at any point the update statment should fail.
The SQL statment is as follows:
IF EXISTS (select from table1statment stating... -
Hi,
you will have to specify a T-SQL statement stating if it fails dont run DTS. Its easy to do it in MS SQL 2005 and it has added features....Leave a comment:
-
-
Hi,
Use the Import/Export wizard to import the excel file into you destination database.
Cheers.Leave a comment:
-
I am not 100% sure but you can try not to use DECLARE and try and save it. Let me know if it helps.Leave a comment:
-
Stored Procedure Help
Hi,
I have written the below stored procedure but whenever i try to execute it it comes up with the error:
Msg 170, Level 15, State 1, Procedure PAGE_COUNT, Line 10
Line 10: Incorrect syntax near ')'.
Stored Procedure is as follows:
CREATE PROCEDURE PAGE_COUNT
@BNAME NVARCHAR(50)
AS
BEGIN
----QUERY FOR THE TOTAL COUNT WITHOUT SEPARATOR
DECLARE... -
Lock Error
Hi,
I get the following error when I try to run an update statement which updates around 200000 rows:
The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions.
Can someone... -
Not Equal To
Hi,
i have two tables with column names in the bracket below:
TABLE 1(A,B,C)
TABLE 2(A,D,E,F)
Column A in both the tables is common.
I need a query in MS SQL which shows me results in which TABLE2.A != TABLE1.A?. I tried it but it shows loads of duplicate TABLE2.A columns.
I hope it makes sense.
Thanks,
Aash.
No activity results to display
Show More
Leave a comment: