sql

Client Components for SQL Server 2005 Enterprise x64 won't install due to Native Client Error

So I got a 64 bit virtual machine running x64 Windows Server 2003 Standard Edition with plesk from blacknight.ie. I installed all the updates from windowsupdate.microsoft.com apart from group policy, terminal services and windows search. I then tried installing SQL 2005 x64 Enterprise. I tell it to install everything including all the cl...

How to connect to a MySQL database from an iPhone?

I am trying to connect to a remote mysql database from an iPhone. I have searched many web sites but I did not find any help. If anyone has worked with this please send a solution. ...

SQL Server - where is "sys.functions" ??

SQL Server 2005 has great sys.XXX views on the system catalog which I use frequently. What stumbles me is this: why is there a "sys.procedures" view to see info about your stored procedures, but there is no "sys.functions" view to see the same for your stored functions? Doesn't anybody use stored functions? I find them very handy for e...

Deploying Sql Server Reporting Services reports on production boxes

How to deploy Sql server reports on productions boxes? Locally it's not a problem, I just specify the url and then right click on project and say deploy which deploy on my local server. But it's not gonna be the case for the production server ...

Source Control and stored procedures

Hi I have been wondering how to put all the stored procedures on a SQL 2000 under source control. We are using Subversion for all our normal source code, so it would be great if there were a solution to the problem using Subversion. Do you have any ideas? Update 16-02-2009: This is the vbs script i used to export all the stored proce...

TOP versus SET ROWCOUNT

Is there a difference in performance between TOP and SET ROWCOUNT or do they just get executed in the same manner? ...

How can I combine multiple rows into a comma-delimited list in Oracle?

I have a simple query: select * from countries with the following results: country_name ------------ Albania Andorra Antigua ..... I would like to return the results in one row, so like this: Albania, Andorra, Antigua, ... Of course, I can write a PL/SQL function to do the job (I already did in Oracle 10g), but is there a nicer,...

Can you access the auto increment value in MySQL within one statement?

Hi! I have a MySQL database which contains a table of users. The primary key of the table is 'userid', which is set to be an auto increment field. What I'd like to do is when I insert a new user into the table is to use the same value that the auto increment is creating in the 'userid' field in a different field, 'default_assignment'....

Cursor inside cursor

Main problem is about changing the index of rows to 1,2,3.. where contact-id and type is the same. but all columns can contain exactly the same data because of some ex-employee messed up and update all rows by contact-id and type. somehow there are rows that aren't messed but index rows are same. It is total chaos. I tried to use an in...

How to Share Data Between Stored Procedures

There were a number of questions related to sharing data results of one stored procedure in another in MS SqlServer. Depending of the version of SQL Server people would suggest using temporary tables, xml (SQLServer 2005) or table variables (SQL Server 2008). There is a great article written by Erland Sommarskog that provides comprehe...

T-SQL, updating more than one variable in a single select

Is it possible to update more than one local variable in a single select? Something like: set @variableOne = avg(someColumn), @variableTwo = avg(otherColumn) from tblTable It seems a bit wasteful to make two separate select operations for something as trivial as this task: set @variableOne = ( select avg(someColumn) from...

Conditional Joins - Dynamic SQL

The DBA here at work is trying to turn my straightforward stored procs into a dynamic sql monstrosity. Admittedly, my stored procedure might not be as fast as they'd like, but I can't help but believe there's an adequate way to do what is basically a conditional join. Here's an example of my stored proc: SELECT * FROM table WHERE ( ...

Best way to parse DateTime to SQL server

I was wondering what is the best way to parse a DateTime object to your SQL server. Where you are generating the SQL in code. I have always used something like DateTime.Now.TolongDateString() and had good results, apart from today where i got a error, and it made me think. System.Data.SqlClient.SqlException: Conversion failed when ...

How do I ALTER a PostgreSQL table and make a column unique?

I have a table in PostgreSQL where the schema looks like this: CREATE TABLE "foo_table" ( "id" serial NOT NULL PRIMARY KEY, "permalink" varchar(200) NOT NULL, "text" varchar(512) NOT NULL, "timestamp" timestamp with time zone NOT NULL ) Now I want to make the permalink unique across the table by ALTER-ing the table. Ca...

Any SQL database: When is it better to fetch a whole table instead of querying for particular rows?

I have a table that contains maybe 10k to 100k rows and I need varying sets of up to 1 or 2 thousand rows, but often enough a lot less. I want these queries to be as fast as possible and I would like to know which approach is generally smarter: Always query for exactly the rows I need with a WHERE clause that's different all the time. ...

Sub Query help required

I need to get 2 summed figures however im having issues as one will be for total orders and one is for orders incomplete. These use the same initial query however the orders incomplete has an additional where clause. Can these be put into a query so that i just get the 2 columns. I have done inner queries before but i have never done one...

Creating trigger for table in MySQL database (syntax error)

I have trouble defining a trigger for a MySQL database. I want to change a textfield before inserting a new row (under a given condition). This is what I have tried: CREATE TRIGGER add_bcc BEFORE INSERT ON MailQueue FOR EACH ROW BEGIN IF (NEW.sHeaders LIKE "%[email protected]%") THEN SET NEW.sHeaders = NEW.sHeaders + "BCC:inter...

Help with writing SQL code: same functionality as Yell.com

Can anyone help me with the trying to write SQL (MS SqlServer) - I must admit this is not by best skill. What I want to do is exactly the same functionality as appears for the seach boxes for the Yell website i.e. Search for company type AND/OR company name AND/OR enter a company name in a Location if anyone can suggest the SQL cod...

Unable to connect to msSQL database via PHP

I am using the current code in attempt to access a msSQL 2005 db: <?php $myServer = "[server]"; $myUser = "[username]"; $myPass = "[password]"; $myDB = "[db]"; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $s...

How can I make this query in SQL Server Compact Edition?

Hi, this subquery works in SQL Server: select systemUsers.name, (select count(id) from userIncidences where idUser = systemUsers.id ) from systemUsers How can It be made in SQL Compact? Thanks! ...