sql

sql server 2008 database merging with another database

I have 2 sql server databases on two different remote servers. On day one, they were both exaclty the same. But over time, there are changes in both (different, tables, stored procs, views, etc..). How do I merge them together, so I have one again - the same Database in both places? ...

How to get SQL Server XQUERY to return something other than "There is no element named [Element]"

Apologies if this is answered elsewhere. I keep getting the error message XQuery [Mytable.XMLData.nodes()]: There is no element named 'Answer' SELECT ref.value('/','nvarchar(1000)') FROM Mytable CROSS APPLY xmldata.nodes('Answer') R(ref) - --XML of Row <Answer xmlns="http://TempNameSpace.com/AnswerData.xsd" Type="Deliverable"> <...

Is it bad to not use a DB but use in memory objects?

I've been tasked to write a small app to be used by a single user. This app will pull in ~500 employee names/departments from our master employee DB. Then the user will enter like 5 fields for each employee. Those 5 fields will typically only change once a year, but could be once a month worst case. I only am supposed to keep track of 2 ...

SQL 2008 SP - Deadlock cause or red herring?

One of my co-workers has a stored procedure that does the following Begin tran 1) Dynamically generate a select statement. 2) Insert into table x 3) Execute the select statement End tran If this stored procedure is ran by two septate threads simultaneously, he gets the following error: System.Data.SqlClient.SqlException: Transaction ...

Running a query with PHP/MySQL then reordering the results by another column.

This SQL query gives me the results I want; however, I want the results ordered by a different column: SELECT * FROM post INNER JOIN account ON post.account_id = account.account_id WHERE post_id > neww ORDER BY post_date ASC LIMIT 10; I can not simply change 'ORDER BY post_date ASC' to 'ORDER BY post_id DESC', while that will...

Question about SQL Server Optmization Sub Query vs. Join

Which of these queries is more efficient, and would a modern DBMS (like SQL Server) make the changes under the hood to make them equal? SELECT DISTINCT S# FROM shipments WHERE P# IN (SELECT P# FROM parts WHERE color = ‘Red’) vs. SELECT DISTINCT S# FROM shipments, parts WHERE shipments.P# = p...

Asp.net User Login Count and LastLogin

Is the normal way to do this to just make 2 cols in my User table, loginCount and lastLogin, and then when a user is Authenticated hit the db and update them in the code behind? I am using OpenID only. Is there a better way? ...

Normalizing a table, from one to the other

Hi, I'm trying to normalize a mysql database.... I currently have a table that contains 11 columns for "categories". The first column is a user_id and the other 10 are category_id_1 - category_id_10. Some rows may only contain a category_id up to category_id_1 and the rest might be NULL. I then have a table that has 2 columns, user_i...

How to convert nested heirarchy of xml to sql table

Using MSSQL 2008 and XQUERY Consider the following XML stored in a table: <ROOT> <WrapperElement> <ParentElement ID=1> <Title>parent1</Title> <Description /> <ChildElement ID="6"> <Title>Child 4</Title> <Description /> <StartDate>2010-01-25T00:00:00</StartDate> <EndDate>2010-01-25...

Keeping Track of User Points (Like SO)

I want to be able to keep track of user points earned on my website. It isn't really like SO but the point system is similar in that I want each user to have a total and then I want to keep track of the transactions that got them to that total. Should I keep a user total in the User table or should I just pull all the transactions that...

Semantics of the Boolean and comparison operators in the context of three-valued-logic

Hi People! Professor ask me this question: What is the semantics of the Boolean and comparison operators in the context of three-valued-logic? I'm not sure what he meant by that. What is comparison operator? Is that the same as relational operator? Semantics? He asking about 'meaning' of those two terms in context of three-valued-log...

MySQL Stored Procedures not working with SELECT (basic question)

Hello, I am using a platform (perfectforms) that requires me to use stored procedures for most of my queries, and having never used stored procedures, I can't figure out what I'm doing wrong. The following statement executes without error: DELIMITER // DROP PROCEDURE IF EXISTS test_db.test_proc// CREATE PROCEDURE test_db.test_proc() S...

How can I merge the columns from two tables into one output?

I have two tables with similar information. Let's call them items_a and items_b. They should be one, but they are coming from different sources, so they aren't. When I full-join the two table, some rows end up with data from either one or both tables. One of the columns in both tables is category_id. I would like to cross the combined ta...

Regarding Execute Immediate in stored procedure

I am having the below statement from stored procedure. It's giving Insufficient Privileges. But If i run the create statement alone from the sql prompt it's creating table. execute immediate 'create table TEST_ABC( NO_AC NUMBER(8) , ILL_PER VARCHAR2(15) , INIT_C DATE ...

Best practice for archiving a huge table of over 1,000,000,000 rows

I'm using SQL Server 2005. There is an audit trail table, containing over 1,000,000,000 rows. I'm planning to archive this table. When I make a simple select with nolock, I can still find blocking (probably IO blocking with other process?). So are there any best practice for this kind of situation? ...

how to delete every alternate row in access table

i have a huge access table containing about 400000 rows . what sql query can i give to delete every alternate row in the table. ? I do have a column in the table which has values from 1 , 2, 3 ,4 .... about 400000 . ...

I have a table “Student”, now I would like to query the result as same as the second table, one group must have 2 students. Thanks!!

I have a table “Student”, now I would like to query the result as same as the second table, one group must have 2 students. Thanks!! Student ID Name Gender Group 1 A M A1 2 B F A1 3 C M A2 4 D M A2 5 E F A3 6 F F A3 Name1 Gender1 Name2 Gender2 Group A M B F A1 C M D M A2 E F F F A3 ...

Understanding how to bind parameters and insert data in Adodb

I was told to use bind parameters so that I could insert text into my db that had quotes in it. But, I am pretty confused when it comes to how to do this, the commands seem confusing to me. So, if I had a php string, that contained html, how would I insert this into my DB using bind parameters? I wanted to INSERT it, how would I do th...

how to insert a collumn with value row number in an access table

i have a large access table . i need to have a column which will have value as row number how can i write an sql query fill an empty column inserted by me with row numbers ...

code for spinning in cocos2d

how can i do spinning in cocos2d(like that of a uipickerview) but i have my own images of the background of the picker, the columns which will spin ? also in a way that the images that will be displayed will vary in each spinning action? about that "random"thing...please help me anyone.... ...