sql

Free SQL comparison tool

I have been using SQL Compare by Redgate at my company and was very satisfied with it. Are there any free comparison tools that are similar? Or what would be my best shot for synchronizing two SQL db's without a paid application ...

How to connect to SQL server through IP

I have a remote server that has win2003 installed I can connect to the machine using remote desktop and am succesfully hosting a web app on the server I need to connect to the SQL server on that machine using a sql compare tool that I have. What are the steps that I need to take to be able to connect to the SQL server given that all I...

Problem with ORs in JOIN statement

I have a problem with the SQL statement detailed below. The query returns the results I need, but takes an insane amount of time to execute. I now have so many records in the db that the page generally won't load. SELECT dscan.guid, dscan.drive, dscan.folder, dscan.filename, source.guid FROM source RIGHT JOIN dscan ON ( (source.gui...

SQL Query, Selecting 5 most recent in each group

I have this table CREATE TABLE `codes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `language_id` int(11) unsigned NOT NULL, `title` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `time_posted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 lan...

C#: Add data to an SQLMetal generated database class?

I used SQLMetal to generate a code file representing my database, and i can't figure out how to add entries to the database from the SQLMetal generated classes. How do i do this? do i just add to the various properties or something? ...

How to write the following in Linq or Sql

Hi, Appreciate if I can get some help writing a LINQ that will get ALL FIELDS from table A, and those fields for which profile 1 has a value in table AB, show the value, otherwise if profile 1 has no entry in table AB, then show value as null. Table A AID Field ----------- 1 OneField 2 TwoField 3 ThreeField Table ...

SQL Server is extremely slow when running queries on the Stack Overflow data dump

I imported the Stack Overflow data dump into SQL Server 2008. Some queries, especially on the Posts table, are taking more than a minute to return. Example query: SELECT Id, PostTypeId, AcceptedAnswerId, CreationDate, Score, ViewCount, Body, OwnerUserId, OwnerDisplayName, LastEditorUserId, LastEditDate, LastActivityDate, Tit...

Hierarchial SQL Query

Hi, I have a self-referencing table (Customers) and a table that will link to one record in that table (Companies) i.e. Customers Companies ********* ********* ID ID ManagerID --> DirectorID ManagerID refers to another record in the Customer table. I need to perform a query where by given a specific customer I...

See what caused a SQL trigger?

I just wonder if it is possible to see what stored procedure or SQL statement that caused a trigger to be executed somewhere in the trigger. I have a really wierd bug where a field is changed and i can't for my life figure out why that is happening. I have a trigger that is logging that the data is changed but it would be great if i als...

How to convert a database file (.sql) to a .mdf file?

I have a database that was given to me, but is in a file format (.sql). I want to open it in my SQL Server, but I don't know how, because it says i need a .mdf file? Can someone help? ...

Should I be using InnoDB for this?

I am developing a personal PHP/MySQL app, and I came across this particular scenario in my project: I have various comment threads. This is handled by two tables - 'Comments' and 'Threads', with each comment in 'Comments' table having a 'thread_id' attribute indicating which thread the comment belongs to. When the user deletes a comment...

Develop for SQL Server Standard using SQL Server Express?

I'm working on a web service project, and I'm coding at home, where I have SQL Express 2008 installed, but the app needs to interface with an SQL Server Standard. I've never done the transition before, and I haven't been able to find any resources on the subject - plenty of stuff about upgrading, but nothing about how to deploy. For ins...

SQL - Left join 2 foreign keys to 1 primary key

I have two tables, Games and Teams. What should my sql statement look like to make a list of games that pulls in the TeamName that is linked to the TeamID1 and TeamID2 fields? I believe I could use a left join but I'm not sure what to do with two foreign keys that link to one primary key. Thank you very much for any help you could provid...

SQL Backup files, distinguish partial and full backup files

I have scheduled backups running through SQL Agent, with Full Backups nightly, and differential backups hourly. Is there a way to determine which of the backup files is the Full backup, and which is the latest differential? Intuitively, it would seem the largest backup within 24 hours is the full, and the latest smaller backup is the...

Create SQL identity as primary key?

create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't work. How can I do this? ...

How can I declare a Boolean parameter in SQL statement?

How can I declare a Boolean parameter in SQL statement? ...

What data-type should I use to store monetary values?

I've read I should use money, but in todays fast paced world maybe that's obsolete now. What should I use? ...

Using the Web.Config to set up my SQL database connection string?

Can anyone help me out please? I'm confused. I want to set up my connection string so I can just call it from my Web.Config file. I need a way to call it from my code, please make a little example. :( I also need help on setting up the Web.Config file. I don't know what properties to use. Here's a screenshot of what my credentials a...

Trouble using my stored procedure.

I have the following method that is supposed to be a generic "Save to SQL" method for my application. protected void EjecutarGuardar(string ProcedimientoAlmacenado, object[] Parametros) { SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); ...

How to add a number to a Sqlcommand.Parameters?

Here's my method: public void EjecutarGuardar(string ProcedimientoAlmacenado, object[] Parametros) { SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); SqlCommand Command = Connection.CreateCommand(); Command.CommandText ...