Cannot truncate table because it is being referenced by a FOREIGN KEY constraint?

Using MSSQL2005, can I truncate a table with a foreign key constraint if I first truncate the child table (the table with the primary key of the FK relationship)? I know that I can either Use a DELETE without a where clause and then RESEED the identity (or) Remove the FK, truncate the table, and … Read more

Insert multiple rows WITHOUT repeating the “INSERT INTO …” part of the statement?

I know I’ve done this before years ago, but I can’t remember the syntax, and I can’t find it anywhere due to pulling up tons of help docs and articles about “bulk imports”. Here’s what I want to do, but the syntax is not exactly right… please, someone who has done this before, help me … Read more

Check if a temporary table exists and delete if it exists before creating a temporary table

I am using the following code to check if the temporary table exists and drop the table if it exists before creating again. It works fine as long as I don’t change the columns. If I add a column later, it will give an error saying “invalid column”. Please let me know what I am … Read more

SQL update query using joins

I have to update a field with a value which is returned by a join of 3 tables. Example: select im.itemid ,im.sku as iSku ,gm.SKU as GSKU ,mm.ManufacturerId as ManuId ,mm.ManufacturerName ,im.mf_item_number ,mm.ManufacturerID from item_master im, group_master gm, Manufacturer_Master mm where im.mf_item_number like ‘STA%’ and im.sku=gm.sku and gm.ManufacturerID = mm.ManufacturerID and gm.manufacturerID=34 I want to … Read more