sql

I want to show records from in 1 row.

Table 1 (history data) SiteName OutcomeType SpeciesType Count DateType ------------------------------------------------------------- S1 Adopted Dog 3 0 S2 Adopted Cat 12 0 S1 Transferred Puppy 2 0 S1 Transfer...

SQL Server 2008: I have 1000 tables, I need to know which tables have data

Is there a way in SMSS to detect whether a table has any records? I need to get a list of tables that have records. perhaps there is a sql statement that will do the trick? ...

Why are self joins faster than or?

I'm trying to filter a relationship table down to get a subset of the table where two conditions are met (ie: I want all of the id's of the entries who's color_ids are 1 or 2). It's a beefy table, so I'm trying to optimize as much as possible. I was wondering if anyone could explain my finding in this case: Why is SELECT DISTINCT a.id...

sql output as a ranking

If I have a table of random values in a sql table, how can I export and display them as a raking rather than the absolute value... for example.. if the three values are 30 85 and 90 how do i get 30 do display as 1 or 1st, 85 as 2 or 2nd etc ...

Declaring and using MySQL varchar variables

I'm trying to do some simple manipulations with variables in MySQL 5.0 but I can't quite get it to work. I've seen many (very!) different syntaxen for DECLARE/SET, I'm not sure why... in any case I'm presumably confusing them/picking the wrong one/mixing them. Here's a minimal fragment that fails: DECLARE FOO varchar(7); DECLARE oldFO...

LIKE with Linq to Entities

I know the .Contains() method does like LIKE %therm%, the .StartsWith() method does like LIKE therm% and the .EndsWith() method like LIKE %therm but... Is there a way to do like below on **Linq to Entities**? SELECT * FROM [dbo].[Users] WHERE Name LIKE 'rodrigo%otavio%diniz%waltenberg' PS: I'M USING LINQ TO ENTITIES. NOT LINQ TO SQL ...

Can a view return multiple result sets?

I would like to have a view that I could run return multiple result sets. Is this possible? If a view can not do this, then is there another object with High Visibility/Transparency within SQL Server that can achieve this? (I like using a view because I can easily see it and run it under the Views folder). A stored procedure is not rea...

How can I force LINQ to SQL to perform an INNER JOIN on a nullable foreign key?

I have a very simple set-up. Table "Node" has a nullable foreign key "ObjectId." This is represented in my database model with a one-to-many association. Now, I want to run a query that gives me all Node-Objects with a particular object id. In straight SQL, this is very easy: SELECT Node.*, Object.* FROM Node INNER JOIN Object O...

Possible to have drupal read from a sql database?

I have a site under drupal (using mysql) but need it to read from a external sql database and make quires/reports, maybe using views2? Is is at all possible? I been looking for a solution to just read (not import, its thousands of entries...) from an external database for hours and not sure if its even possible. ...

Why doesn't Entity Framework easily allow a custom base class?

Is this a design choice by Microsoft, or is there a way to do it, that I'm not aware of? ...

why an oracle procedure is invalid

Can someone please explain to me why I keep getting this PLS-00905 error for the below simple procedure? Thank you. create or replace procedure copy_table( table_name IN varchar2, database_link IN varchar2, suffix IN varchar2, table_owner IN varchar2) IS begin execute immediate 'create table ' || table_name || '_'...

Can I call a Web Service from SQL Server 2005?

I want to call a web service from my SQL code, but it cannot be using CLR code. Can this even be done? ...

passing parameter from access into sql-server

REPHRASING QUESTION: i apologize for being unclear. i have a textbox and a button a form. when the button is clicked it runs this saved access query: select * from sqlservertable where field=form!textbox.value i have an access front end and sql server back end. this query is not working. it doesnt like me passing this parameter form...

SQL Trigger - Maximo Workorders - Supervisor/Owner Initialization

I am working with an IBM Maximo database that issues workorders automatically. When the workorders are issued (aka Inserted into the database workorder table), I would like to auto-assign a supervisor, owner, and owner group based on a set of criteria. This only needs to happen IF the supervisor, owner, and owner group aren't already ass...

What is the best way to design this particular database/SQL issue?

Here's a tricky normalization/SQL/Database Design question that has been puzzling us. I hope I can state it correctly. You have a set of activities. They are things that need to be done -- a glorified TODO list. Any given activity can be assigned to an employee. Every activity also has an enitity for whom the activity is to be perf...

Generating select statement with joins from table information.

Hello, I've got a bunch of classes that describe database schema: Table,Field,ForeignKey. Tables have ForeignKeys list and Fields list. Now I would like to generate SELECT statement with all the joins that are described in ForeignKey instances. The question is: is order of tables relevant for the query time? Another words - do I have ...

c# Object obj's value is {}. What is "{}"?

I'm using some old code that runs a sql query as a reference. At some point, it gets to something like: sqlDataAdapter.Fill(dataSet); DataRow dataRow = dataSet.Tables[0].Rows[0]; Object obj = dataRow[fieldName]; The old code does: string output; if (!string.IsNullOrEmpty(obj.ToString())) { output = obj.ToString(); } else { output = ...

Finding matches in multiple columns in different orders

Hello, I am trying to merge 2 databases with the same schema together, and this is one part of it. I have changed the subject to keep it more understandable - I cannot change this schema, it's just what I'm working with. I have a table in both my source and target databases with the following columns: Car CarType1 CarType2 CarType3 C...

C++ SQL Queries/SQL Wrapped for C++?

Just more a general question I can't seem to find a definite answer on. But what is a good SQL wrapper for C++ that allows me to call queries? I'm used to Oracle, but i've used MYSQL before aswell. And how would you call something such as an insert statement (for example) in one? ...

How to deal with null values in Word VBA SQL query?

Hi, I have a dropdown that is bound to a column in an excel spreadsheet. I select a customer in the dropdown and then populate some address fields with related data also from the excel spreadsheet. Code: Private Sub cboCompany_Change() Dim customerName As String customerName = cboCompany.Value custo...