Skip to content

Tag: sql-server-2005

SQL Query to determine number of tables

I have this table and I’m trying to determine how many Tables (in a restaurant) are awaiting food. The table( in the database) has the following columns: TableNumber, ObjectType, ObjectDescription and Quantity (amongst others). I made this query to see what is ordered, but would like to know how many un…

Build combined table from 2 uneven tables

I have 2 uneven tables which I am trying to build into 1 table, each table has a date and ID to join with, the issue is that sometime 1 table can have rows with no matching date in 2nd table Initially table 2 seemed to always have an entry for table 1 so I was doing a left join

My script has no effects in more than 3 rows

The script works fine when it has 2 rows. Stop reading from 3. This is MSSQL Server 2005. Try anyway without any result. There is no error message. But if I have more than 10 rows, it doesn’t affect the row that should affect. Answer Given the new information in your comment you should simplify this to …

Update and insert to one table from another

I have two tables: table1: (ID, Code, Name) table2: (ID, Code, Name) with same columns I want to to insert data from table1 to table2 or update columns if that exists in table2 (table1.ID = table2.ID) What is the simple way to do this? WITH OUT MERGE Answer There are some issues with Merge statement,so it sho…