sql

If I build a solution in C#, how do I add a database to the final program?

Apologies if this is a very basic question, but I am preparing to create an executable for a Visual Studio C# Application. (My first time!) My application uses a database that I'm currently storing in SQL Server. This works fine while I'm coding since I created the database manually on my computer. I see that VS2008 has created an .ex...

How to Set Customer Table with Multiple Phone Numbers? - Relational Database Design

CREATE TABLE Phone ( phoneID - PK . . . ); CREATE TABLE PhoneDetail ( phoneDetailID - PK phoneID - FK points to Phone phoneTypeID ... phoneNumber ... . . . ); CREATE TABLE Customer ( customerID - PK firstName phoneID - Unique FK points to Phone . . . ); A customer can have multiple phone numbers e.g. Cell, Work, etc. phoneID in Custo...

Using IN with sets of tuples in SQL (SQLite3)

I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation varchar(20), other_annotation varchar(20), set1_size INTEGER, set2_size INTEGER, jaccard REAL, p_value REAL, bh_corrected_p_value REAL, PRIMARY KEY (neighbors_of_annotation, other_annotation) ); I would like to perform the followin...

SqlCe Connection count

Is there a way to determine the number of connections say a windows application has open with SqlCe? ...

Search & Replace SQL

I am messing around with one of my databases.. is there away for me to search for a string in ALL the tables.. and replace it with another everywhere it occurs? I am looking for SQL ...

Comma-separated value insertion In SQL Server 2005

How can I insert values from a comma-separated input parameter with a stored procedure? For example: exec StoredProcedure Name 17,'127,204,110,198',7,'162,170,163,170' you can see that I have two comma-separated value lists in the parameter list. Both will have the same number of values: if the first has 5 comma-separated values, then...

Deleting Multiple Rows with Zend DB Table Problem

I have this data in my db Col1 Col2 DA Data1 DA Data2 DA Data3 DA Data4 DA Data5 I would like to delete all the values WHERE col1 = DA using my Zend DB Table adapter. The code below does not seem to work for multiple rows public function delete($key) { $this->delete('Col1 = "'.$key.'"'); ...

SQL Get UID when Group by

I do a select from table [V_RPT_BelegungKostenstelleDetail] WHERE SO_UID = '7C7035C8-56DD-4A44-93CC-F16FD66280A3' AND GB_UID = '4FF1B0EE-A5DD-4699-94B7-760922666CE2' AND GS_UID = '1188759A-54E1-4323-8BF2-85E71B3C796E' AND RM_UID = '088C3559-6E6E-468A-9554-6740840FCBA1' AND NA_UID= '96A2A8DB-8C83-4C60-9060-F0F55719AF5C' GROUP BY KST_UI...

Small standalone SQL database similar to access in the old days(ie file database)

Hi, I am looking for a easy to use and deploy sql type database i can ship with a desktop application. This will be a small application user's can download from my website. In the vb6 days, access was the common database for small desktop apps, what is my option these days? Looking at SQL CE it seems to have a quite a few limitations...

SQL COUNT records in table 2 JOINS away

Using MySQL, I have three tables: projects: ID name 1 "birthday party" 2 "soccer match" 3 "wine tasting evening" 4 "dig out garden" 5 "mountainbiking" 6 "making music" batches: ID projectID templateID when 1 1 1 7 days before 2 1 1 1 day before 3 4 2 2...

SQL Server 2005 Full text search - Searching for numbers

Hi all, I using the SQL Server 2008 FTS feature in a project. When searching for a phone number like CONTAINSTABLE(table, *, '"017394708699"'), this query also returns records containing the number '017394689966', which is similar. Does anyone know how I can get an exact match from a number? ...

Excluding records based upon a one to many SQL join

How would I write a SQL query that excludes a record if one (external) record from a one to many join matches a certain condition? For example: Details ID 1 2 Items DetailID Item 1 A 1 B 2 B 2 C How would I select the detail records where the Items do not include 'A'...

Sql's query analyzer for visual studio

Hi, I do a lot of mistakes in sql query in visual studio 2008. is there any addin, which can analyze my query? ...

A column insert or update conflicts with a rule imposed by a previous CREATE RULE statement.

I'm working on a online game. I got some problems with inserting new data to table. I'm getting 2010-4-8 2:14, 37000, 513, [Microsoft][ODBC SQL Server Driver][SQL Server]A column insert or update conflicts with a rule imposed by a previous CREATE RULE statement. The statement was terminated. The conflict occurred in data...

Databases Views with Parameters

Hi there, I know that is it possible to create a View with Parameters at MSSQL, does anyone knows if I can achieve something similar with a DB2 database? I have a more complicated query which includes a user number which I want to pass as param to the view. ...

SQLServer triggers

Please help me to write trigger that, adds new rows in table I have 3 tables in my database. Regions (id, name); id - primary Technics (id, name); id - primary Availability (id, region, technic, count); id - primary, region - foreign on Regions.id, Technik - foreign on technics.id I want to add new row in Availability for each Tech...

I've caught an exception!! Now what?

Hi folks, I've started using try catch blocks (bit late i know!) but now im not sure what to do with the exception once i've caught it. What do people usually do here? -- Jonesy Try connection.Open() Dim sqlCmd As New SqlCommand("do some SQL", connection) Dim sqlDa As New SqlDataAdapter(sqlCmd) ...

Are there more secure alternatives to the .Net SQLConnection class?

Hi SO people, I'm very surprised this issue hasn't been discussed in-depth: This article tells us how to use windbg to dump a running .Net process strings in memory. I spent much time researching the SecureString class, which uses unmanaged pinned memory blocks, and keeps the data encrypted too. Great stuff. The problem comes in when ...

sp_executesql with 'IN' statement

I am trying to use sp_executesql to prevent SQL injection in SQL 2005, I have a simple query like this: SELECT * from table WHERE RegionCode in ('X101', 'B202') However, when I use sp_executesql to execute the following, it doesn't return anything. Set @Cmd = N'SELECT * FROM table WHERE RegionCode in (@P1)' SET @ParamDefinition = N'...

Problem with write query

Hi, I've got collection of geo objects in database: There are four Tables: Countries Regions Provinces Cities Cities has inter alia ProvinceCode Provinces has inter alia regionCode Regions has inter alia CountryCode And there is fifth Table: Descriptions ObjectCode ObjectType(country, region, province, city) Description. How to ...