sql

SQL server profiler not showing LINQ To Sql queries

I am trying to view SQL generated by Linq to SQL in the SQL Server Profiler (2005). I can see the sql sent to the server from anything except for linq to sql. I'm betting that I need to change event selections for the trace, but not sure what else to select. I am currently only selecting this: SQL:StmtCompleted - TextData & SPID I do...

Asp.Net Adding Images to SQL Table...What am I doing wrong?

I have done this previously but in a different way. I am trying to get the code below to work. If I do not cast 'OriginalPhoto' or 'Thumbnail' an error occurs. Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query. I don't understand why it asking to cast. However if I do ...

SQL Stored Procedure : Incorrect syntax within imbricated IFs

I get "Incorrect syntax" errors on every nested IF and ELSE statements in the following code... what's wrong ? ALTER PROCEDURE [WTFAULT].[usp_WTFault_GetPartFaultStatus] ( @linxPartId int = -1, @faultStatus varchar(10) output ) AS BEGIN DECLARE @NbFaultsInParts int, @NbPartsReturned int SET @NbPartsReturned = (SELECT COU...

Using SQl Server CE; Possible to Insert Only If Not Exists and Delete if Exists?

I have a One Field Table in SQL CE which I need a SQL Statement for. The objective is to Delete the record if it already exists and insert the record if it does not exist. Is the possible with SQL CE? INSERT INTO Source_Table SELECT 'myvalue' AS Expr1 WHERE (NOT EXISTS (SELECT Source_Data FR...

getting the MSSQL Schema for a table

I have the following C#.Net code that I am trying to get to return the stored procedure results along with the schema of those results. Below is how my code (simplified) currently looks... Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("MyStoredProcedure"); IDataReader drData = db.ExecuteRe...

Return surrounding text for phrase found in full-text search, SQL 2005

I'm using a contains predicate to find phrases in a SQL Server indexed text field. Is there a way to return the portion of the text field that contains the searched phrase, or some area around it? For example, if I'm searching for "all men are created equal" in the Gettysburg address (excerpted below), I'd like to return "dedicated to ...

Is Unit Testing your SQL taking TDD Too far?

There is an article out on www.sqlservercentral.com about unit testing your SQL. The TDD Guy in me said good, we can test the database stuff. The System Architect in me said, what logic are we testing? There shouldn't be any logic in the database, the only thing you should be doing in the data base is selecting, updating, or inserting....

Do DDL statements always give you an implicit commit, or can you get an implicit rollback?

If you're halfway through a transaction and perform a DDL statement, such as truncating a table, then the transaction commits. I was wondering whether this was always the case and by definition, or is there a setting hidden somewhere that would rollback the transaction instead of committing. Thanks. Edit to clarify... I'm not looking...

SQL: 3 self-joins and then join them together

I have 2 tables to join in a specific way. I think my query is right, but not sure. select t1.userID, t3.Answer Unit, t5.Answer Demo FROM table1 t1 inner join (select * from table2) t3 ON t1.userID = t3.userID inner join (select * from table2) t5 ON t1.userID = t5.userID where NOT EXISTS (SELECT * FROM ...

Oracle Throwing SQL Error when creating a View

Hi all, I'm trying to create a view in an Oracle database, but keep getting an ORA-00907 error (missing right parenthesis). My SQL is as below: CREATE VIEW my_view AS ( SELECT metadata.ID,metadata.Field1,metadata.Field2,metadata.Field3,metadata.Field4,attribute1.StrValue AS Attr1, attribute2.StrValue AS Attr2 FROM metadata,data AS at...

full-text index returns incorrect results

I created a full-text index on a text column and subsequent contains queries return results that don't include the search term. An example query is: SELECT TOP 10 serial_no,writer_id,myField,assignment_type,subdate,title FROM writing WHERE contains(myField,'"take it once"'); ...

Copy Query Result to another mysql table

I am trying to import a large CSV file into a MySQL database. I have loaded the entire file into one flat table. i can select the data that needs to go into separate tables using select statements, my question is how do i copy the results of those select queries to different tables. i would prefer to do it completely in SQL and not have ...

What changes do I need for my tables to work on AppEngine's BigTable?

Let's say I have a booking database consisting of users: user_id fname lname and their tickets ticket_id user_id flight_no and associated flights flight_no airline departure_time arrival_time What would I need to change to move this Google AppEngine? I understand AppEngine doesn't allow joins. Does that mean my table should be...

Need some suggestion for a database schema design

I'm designing a very simple (in terms of functionality) but difficult (in terms of scalability) system where users can message each other. Think of it as a very simple chatting service. A user can insert a message through a php page. The message is short and has a recipient name. On another php page, the user can view all the messages ...

T-SQL EXEC and scope

Let's say I have a stored procedure with this in its body: EXEC 'INSERT INTO ' + quotename(@table) ' blah...' SELECT IDENT_CURRENT('' + @table + '') Is IDENT_CURRENT() guaranteed to get the identity of that row INSERTed in the EXEC? IDENT_CURRENT() "returns the last identity value generated for a specific table in any session and any ...

Using a UUID as a Database Primary Key, Java type is a byte[]

Are there any issues with using a byte[] as a primary key in a JPA Entity? I want to use a UUID as my primary key, but stored as a string I feel it will be too large. I was thinking of doing something like this to store the ID as a byte[] and set it as my Entity's ID: public static byte[] byteArray(UUID uuid) { long lsb = uu...

ASP.Net Display Images in a GridView span across columns and rows? Using C#

I have some thumbnails I want to display in a Gridview. I am not familiar with all the customization that is offered. Basically I want to store the images in a Gridview, maybe spanning 5 columns wide...and then however many rows it takes to complete the rest. I don't want any column or row titles, and really don't want to see evidence of...

Migrating Database SQL Server to Sybase

Hey folks, I'm migrating a database from MS-SQL to SyBase 15.2, please propose any tools which can assist me on this task. also please post your experience with SyBase, especially the Replicator. Many thanks ! ...

Table design

I was wondering is this a good design, assuming the tables as follows ADDRESS(id, address, city_fk, stateFK, countryFK), CITY(id, name, stateFK, countryFK), STATE(id, name, countryFK), COUNTRY(id, name) Notice how country fk is repeated in 3 tables? and state fk repeated in 2 tables? Can anyone tell me if this is a good design? If s...

loading a double linked list from a sql database

so this is what I got... QueueList {Id,Queue_Instance_ID, Parent_Queue_Instance_ID, Child_Queue_Instance_ID} what will be the most efficient way to stuff this into a LinkedList<QueueList>? basically do you think I can go lower than o(n^2)? thanks. ...