sql

Default sizes for SQL parameters in ADO.NET

There are multiple overloads for sqlcommand.Parameters.Add(...) function. Some of them do not take size, and some do. What sizes are set by default? Is it safe not to set parameter sizes? Does it affect performance? ...

Export DBML to SQL script

Due to a harddrive crash, I lost my SQL server database files for a project I was creating. I still have my DBML files I used in my .NET project, so I still have the database structure in a file. Is it possible to export my DBML somehow to a SQL server script, to recreate my databases in SQL server. ...

random values from db in c#

How can I retrive random random ItemIDs from the list of existing ItemIDs in ItemID column intge db, given below is the sqlcommand I've used. (SqlCommand RetrieveComm =new SqlCommand("SELECT * FROM item_k WHERE ItemID='" +intGetRequest+ "'", searchCon)) thanks, ...

Advanced (?) SQL Joins?

I am a bit lost as to how to explain this, so I will try to give an example of some tables (+ data) and then the result that I am after (all my table columns are NOT NULL): Table: Customers Id int primary key Name varchar(250) Table: Stats (Date, CustomerId is the primary key) Date (date) CustomerId (int) - foreign key to Customers t...

SQL Server 2008 T-SQL Join problem

Followed up by a new question, that contains the question as text, not as an image like this one: http://stackoverflow.com/questions/904209/sql-server-2008-t-sql-join-problem-ver-2/904450#904450 (This question is an image. Right click on "I have some table with value". :) The query should automaticly work if a new position record i...

How to transform SQL table of data into table of pointers ?

Let's say I have an SQL table of tuples (id, lastname, firstname, occupation) where all values are strings (ok, obviously id is a key). I want to transform it to a table with tuples (id, lastid, firstid, occupid), where I only keep pointers to other tables that contain the actual values. I apologize if the example domain of names and oc...

SQL Server 2008 T-SQL Join problem ver 2

I have some table with data Category CategoryID CategoryName 1 Home 2 Contact 3 About Position PositionID PositionName 1 Main menu 2 Left menu 3 Right menu ...(new record can be added later) CategoryPosition CPID CID PID COrder 1 ...

mysql not updating from php form

I have a very simple PHP form, which shows a checkbox, and will store if it is checked or not in a database. This works for the initial inserting, but not for updating. I have tested cases where $saleid equals $pk and it does not enter the if branch to update...why? <?php error_reporting(E_ALL); if (isset($_GET["cmd"])) $cmd = $_GET[...

How do I sort into a dynamically generated specific order in mySQL?

I've been beating my brains in over this and I'm making no progress. I'm not very good with SQL so I'm hoping the answer is something simple that I just don't know. I have 2 tables: One called "images" that contains the data I want, organized with a primary key "imageID". The other is called "productPhotos", and it contains two fields (...

What is the difference between Join and Union?

What is the difference between Join and Union? Can I get a sample? ...

Recordset in VB6.0

Hi, I'm retrieving Data from a Database in a record set using VB6... so while retrieving data using Select in SQL I added a column called Comments along wit it so that in the recordset, all the columns of the table+'Comments' column would be present... I don't want to(and also I cannot) update any contents in the database as i'm only 'fe...

How do i merge these two database tables into a single result set?

Hi folks, I have two tables in the system. I'm trying to make a VIEW that represents them both together, and i'm not sure how this can be done or even IF this can be done. Pets PetId INT PK Name VARCHAR(100) PetOtherNames PetID INT PK FK Name VARCHAR(100) PK So, i have a table of pets. The name (in this table) is their formal co...

Fast way to get the difference of 2 columns in MySQL

Hi, how do I get the fields of a column that's without a match in another column? I tried: SELECT table1.page_title FROM table1, table2 WHERE table1.page_title != table2.page_title It produces a lot of duplicate fields so I did a: SELECT DISTINCT table1.page_title FROM table1, table2 WHERE table1.page_title != table2.page_title ...

TSQL Comma Separation

I'm writing an export function, where I need to export contacts to Excel, and I've run into a technical snag - or perhaps a gap in my SQL skills is closer to the truth. ;) Here's the scenario: I've got a bunch of contacts in a database. Each contact can have many different roles, for example a contact can be both C# Developer and DBA, o...

MySQL: Collect records from multiple queries into one result

I am looking to create a SQL query that collects the results from multiple queries. I would like to apply a random sort order and return a limited number of the records. The queries will all return the same field ("RefCode" in this example), but will have different FROM and WHERE statements. See an example below of some possible queri...

sqlserverquestion

how to write 2 tables and how insert into it in a single statement ...

Problematic delete with SQL index

I have some table: table ASK with idask table PREFERENCES with idpref, fk_idask, fk_idstructure table STRUCTURE with idstructure With all the constraint between the id and the fk_id and a unique index on the table PREFERENCES (fk_idask, fk_idstructure). The problem is when I have two row in PREFERENCES. `IDPREF` `FK_IDASK` `FK...

Executing SQL Query after particular point iof Time

hi all, In our project we have requirement that, after receiving sms message from third party service provider exactly after 3 minutes i need to execute a sql query to update database. how should i do this , any suggestions are accepted. ** is it possible using stored procedures... Exactly the scenario is , we are having mediator s...

unique indexes and include statements

create unique index In DB2 UDB I can create an index using the following syntax create unique index I_0004 on TABLENAME (a) INCLUDE (b, c, d); where a, b, c and d are field of the table TABLENAME. In DB2 for os390 this syntax (the INCLUDE keyword) is not allowed, so I am creating the indexes as follows create unique index...

Creating a trigger dynamic

I use MS SQL 2008 and I want to create a trigger in a database that is created dynamic. Creating the database is called within a stored procedure of an other database and runs perfectly, but when I want to add a trigger or a stored procedure, the executing fails. If I try to run the dynamiy SQL with an EXEC('USE dbase GO CREATE TRIGGE...