sql

Visual Studio - Change datasource after initial database server is down?

Ok, so I've got this Visual Studio 2008 Project I was working with about a year ago perhaps. And this project had a datagrid that was linked to an external database running on a server off the internet. Now, this databinding was all done using Visual Studio 2008's built in features. But how can I now change the binding to a different se...

NTEXT comparison

Hello all, What's the right way to compare NTEXT column with a constant value? If I use something like [ntext2] <> '1,032.5', I get this error: The data types ntext and varchar are incompatible in the not equal to operator. The best possible solution would be if comparison is implemented in the same way for any column type. (<...

Specific day of current month and current year from date time SQL Server 2005

Hello everyone i want search data from invoices and client by today date I'm using DateDiff() GETDATE() functions for example two tables 1 Client - ID int - Name Varcher 2 Invoice - ID int - ClientID int - date Datetime - Total money query Select * from client c inner join invoice i on c.id = i.ClientID WHERE DateD...

MySQL table PRIMARY KEY question?

I' was wondering should my primary key look like this PRIMARY KEY (id, category_id, posts_id) or look like this PRIMARY KEY (id)? Here is my MySQL table. CREATE TABLE posts_categories ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, category_id INT UNSIGNED NOT NULL, posts_id INT UNSIGNED NOT NULL, date_created DATETIME NOT NULL, PRIMARY KEY...

subtracting timestamps

I thought this would be a really simple thing, but I'm having a hard time finding any answers! I have a support table, with added_on and closed_on fields that track when support tickets were opened and closed. I'd like to run a query that (closed_on - added_on) to show the duration a ticket was open. Both fields are timestamp format. T...

Application Type

When developing a stand alone application for windows, what type of application should i use. CLR MFC Win32 The application will be connected to an SQL Database, have multible forms, use a Ribbon Bar. If anyone needs more info to answer this question please let me know. ...

SQL highscores.

Ok, I have two MYSQL tables: CREATE TABLE `sessions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userID` int(11) NOT NULL, `runTime` int(11) NOT NULL, `monstersKilled` int(11) NOT NULL, `profit` int(11) NOT NULL, `tasks` int(11) NOT NULL, `xpGain` int(11) NOT NULL, `lastupdate` int(11) NOT NULL, PRIMARY KEY (`id`) ); An...

SQL UNION with conditions and recursive

Hi, i'm having problems with 2 query for my DB class. I have one table "clients" with this columns: name | id | date | points | REFERRAL --------------------------------------------- daniel | 123456 | 01-01-01 | 50 | 321321 jack | 321321 | 01-01-01 | 30 | 555555 Note that daniel was refered by jack 1) With the ID...

Selecting leaf id + root name from a table in oracle

I have a table that is self referencing, with id, parentid (referencing id), name, ordering as columns. What I want to do is to select the first leaf node of each root and have a pairing of the id of the leaf node with the name of the root node. The data can have unbounded levels, and siblings have an order (assigned by the "ordering" ...

I need a SQL statement that returns the number rows in a table with a specific value.

I'm sure this will equate down to the use of the COUNT statement but I'm not very good at SQL. Here are my SQL Tables. Teams Table: TeamId TeamName RosterSpots ----------------------------------------------- 1 Miami Heat 12 2 New York Knicks 10 Players Table: PlayerId PlayerName ...

Anybody using SQL Source Control from Red Gate

Hi all, We have been looking into possible solutions for our SQL Source control. I just came across Red Gates SQL Source control and wondered if anyone has implemented it? I am going to download the trial and give it a shot, but just wanted to see if others have real experience. As always greatly appreciate the input --S ...

Querying with LINQ basic question

I actually have two questions today, but they are both small :-) 1) Where is a good resource for learning linq/sql selections in C#? 2) Say I have a table called Model, with properties Name, Color, Shape. How do I do a query to select only the rows which DONT have null values in any column. I've tried: var d = database.Portfolio.Sele...

How do i insert data into 1 table from 2 other tables?

My 1st table would be port which has columns status,destination,ferry that i wish to insert My 2nd table would be users which has columns Username that i wish to insert How would i use insert statement and insert all these columns in table Booking? private static final String DATABASE_CREATE = "create table user (_id intege...

ODBC to SQL DATABASE using C# ADO.net

I have MYOB (AccountingSoftware) Database which I can read using ODBC. Now I have dataset containing all tables of MYOB database. What is best way that I can convert this Dataset into SQL Database. Where all tables are created automatically and data inserted automatically. ...

generating an SSRS report without hard-coding a query

Hello, I've just started working with SSRS 2008 and SQL Server 2008. I am trying to create a report that involves querying about certain sectors and their sub sectors (for example a sector would be something like 'financial sector' and its sub sectors would 'bank', 'transfer'...etc ). However, the sectors and sub sectors are changing s...

bcp queryout "for xml path" delimiters

Hello, I am trying to export to xml file using bcp command with queryout and select... FOR XML PATH option. I have a test data of 5000 records. Expected output is: <row> <column1><\column1> <column2><\column2> <\row> *line break here* <row> <column1><\column1> <column2><\column2> <\row> *line break here* However, bcp doe...

How do I JOIN a third table in my SQL statement which returns a COUNT without losing the 0 count items?

A continuation from this question I need a SQL statement that returns the number rows in a table with a specific value. We left off with a SQL statement as follows... SELECT t.teamid, t.teamname, COALESCE(COUNT(p.playerid), 0) AS playercount, t.rosterspots FROM TEAMS t LEFT JOIN PLAYERS p ON p.team...

Error when trying to run an update statement and getting "SQL statement is nested too deeply"

Hi All, I am getting this error when I run a certain SQL statement. I have looked into this and haven't really got anywhere. Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries I cannot post the actual query with data as it contains some sensative information but basically I ...

Include in .net Application Setup File .. SQL SERVER 2005 Express

My application required SQL SERVER 2005 Express edition. so how can i make setup to include this setup and run behind setup ...

Why groovy sql remove schema name from SQL queries?

I need to execute this query: Select * from my_schema.table_within_schema Unfortunately groogy.sql.SQL is removing my_schema and executing a query without schema information: Select * from table_within_schema I wonder if it is possible to force groovy.sql.Sql to keep a schema name in the query. Groovy: 1.7, Db: I use a jdbc dr...