sql

SQL Server 2008: should I be using Windows auth or SQL Server auth?

I have an MS-Access 2007 front end. I will have multiple users on it. They are all going to be on the network company domain. Should I be using Windows authentication or SQL Server authentication to be connecting to SQL Server 2008 via ODBC? ...

Database tables, one table referencing multiple unrelated tables

This question has come up a few times in various forums in my searching, but none have provided a concise resolution. If I have the following tables: User +- id +- username +- password Article +- id +- title +- content and I want to join them in order to determine who created what articles, I could simply add the column user_id to A...

SQL Server: setting variables from query output

Hey all, I am wondering how to set variables to the output of the following query string: SELECT count(*) fees_quantity, 1.5 fees_price, 1.5 * count(*) fees_amount, round(SUM((CONVERT(int,Points) * .1)),0)) redep_amount, round(SUM((CONVERT(int,Points) * .1)),0)) + 1.5 * count(*) total_amount FROM tblHGP HGP, OrderDetail...

Actually im developing a vb .net desktop app that needs to restore a database using a .bak How to do that?

Im getting this: "Exclusive access could not be obtained because the database is in use. RESTORE DATABASE is terminating abnormally." First the message told me i must connect to master db to execute the restore but i change it and i got the message above. The parametrized sql statement im using is : cmd.CommandText = "RESTORE DATABAS...

Foreign key null - performance degradation

I have table folder where column parent_id references on id if that folder has parent, if not then parent_id is null. Is that ok solution or I need extra table for this connection or other solution? Can foreign key be null at all, and if can is this solution will has bigger time execution ? table folder( id int primary key, ...

How do I select all the columns from a table, plus additional columns like ROWNUM?

Hey guys, I'm sure this is an easy question, but I have looked around and haven't found a way to do it. In Oracle, I know it's possible to do a select statement that returns the row number as a column in your result set. Example: select rownum, column1, column2 from table Returns: rownum column1 column2 1 Joe...

MySQL STR_TO_DATE glitch?

I'm running into a problem with MySQL's STR_TO_DATE function. For example, this code: SELECT STR_TO_DATE("Saturday October 23 2010 11:00 AM", "%W %M %d %Y %h:%m %p"); outputs this: 2010-00-23 11:00:00 Why is everything correct except the month? Is this an error in my syntax? ...

NoSQL: DB and language suggestions

In our web project we decided to use NoSQL, but are unsure of which NoSQL solution to use, and which languages have full support for NoSQL. Our priorities are: availability of tutorials and support, and ease of implementation and maintenance. And we want to save the data which is from client side into both relational database (in MySql...

MYSQL - Difference between IN and EXIST

MySql question: What is the difference between [NOT] IN and [NOT] EXIST when doing subqueries in MySql. ...

what method is the most used and efficient to copy "database schema" to other servers not the db!

servers all sql server 2008, and win xp i have the following task create a huge database, DONE distribute it to the 20 waiting servers!! if there were two or three i would have taken the trouble of creating the db's on all of using sql server managemnt stdio but i am guessing that there is an efficient way please note, only the co...

Selecting all users within n-th degree of connection

Hi, The table consists of columns user1, user2, connectionStrength and the example records are the following: A,B,0.2 A,C,0.5 A,G,0.1 B,C,0.8 W,Q,0.4 G,Q,0.5 I would like to retrieve all users within the defined degree of connection for the selected user and then draw a graph of connections. The question however is how to select all ...

Finding a node with no children in a tree like structure with Rails

Hi, I have a tree like structure roughly like this: class Node < ActiveRecord::Base belongs_to :parent, :class_name => self.to_s, :foreign_key => 'parent_id' has_many :children, :class_name => self.to_s, :foreign_key => 'parent_id', :dependent => :destroy ... end I can load all nodes that don't have a parent with this sco...

Import CSV within SQL Server 2008 Management console

I'm trying to import a CSV file within the SQL Server Management console. The CSV is comma delimited. I have some columns that has a comma within double quotes, it seems that SQL Server splits the value in 2 columns. How can I solve this? I hope you can understand what I mean. Thanks in advance. ...

SQL error when opening view

I have an sql server view which I've recently added a field to the underlying table and the view itself. I can open the view just fine on the server, but when I try to run it in SQL management Studio on my PC, I get the following error: > Msg 7352, Level 16, State 1, Line 2 > OLE DB provider 'SQLOLEDB' supplied inconsistent met...

how to return a dynamic result set in Oracle function

I found a string tokenizer query on the net and packaged it into the below function, which return the dynamic set of tokens. The function compiles successfully but somehow I get the error "ORA-00933: SQL command not properly ended". Can someone please help me debug this? Thank you. CREATE OR REPLACE TYPE KEY_VALUE_TYPE is object (k varc...

Flattening columns in a one-to-many relationship in Oracle 10g

I'm guessing this is a matter of figuring out what oracle command to use, but after a couple of hours of googling, I haven't found anything that can do what I need. So here's what I need to have happen in a nutshell: Table 1 Table 2 | PrjID | | PrjID | UserID | |----------| |----------|------...

How to seperate string into 3 columns

I have a column of user names. They are as follows: 'first last middleinitial' Notice the large spaces between the name parts, these are always a different number of spaces. Question: How would I separate first, last, and middleinitial into separate columns (even if the spaces are different for every name)? ...

How do i query data from SQL Server 2005/2008 databases to iPhone

Hello, I am trying to figure out how to utilize exisiting SQL Databases with my iPhone apps. What i am trying to do, is have a search function. The user inputs a keyword, i would then query my SQL database dependant on the user input and return the results from a database. How do i do this with the iPhone? EDIT: I mean SQL Server 200...

How do I convert a "legacy" left outer join statement in Oracle?

I have two tables (A and G) in an Oracle database that can be joined together based off an account number. The one caveat to this is that one of the tables (G) has about 80 fewer records than the other. When I query the two tables together, I need to get all of the rows, so that we see NULL data in the columns for the missing 80 rows. I...

Reading XML that is saved as text from SQL

this is what my query looks like: select top 5 cast(content_html as xml) as [prodxml], prodxml.value('data(ClassTemplate[1]', 'nvarchar(max) ') as prod2 from content where end_date >= getdate() and folder_id != 71682 and i keep getting: Msg 4121, Level 16, State 1, Line 1 Cannot find either column "prodxml" or the user-defined f...