sql

c# linq to sql with a stored procedure containing dynamic sql

Hi, I have a stored procedure that contains dynamic sql to return a result set. The query runs fine, but I can't use it via Linq to sql. It appears that the Data Class designer deems that the query only contains one column (Location) rather than the correct number. I'm guessing its because the dynamic sql means that the columns are no...

Converting a "DBML" file to a "SQL database file"

I have the DBML file of a database and would like to generate an SQL database file from this file. Thanks ...

SQL Server Compact. There was an error parsing the query.

I cannot figure out why this is not working. I get the same thing when I try to do an update query as well. Here is the error " There was an error parsing the query. [ Token line number = 1,Token line offset = 43,Token in error = where ] " Here is the actual Query INSERT INTO ads (title,price,body,enabled,where,interval,posted) VALUE...

Dynamic DB storage based on unknown result from source

I have a source of data that I get from a webService. I can never know when it'll change and I need to store it in a DB as soon as I get it. What is the best way to make the storage solution adapt to what I put there. I am using mySQL. Would serialization be the key? ...

SQL Performance (Replace)

Hey, I have a table that has about 400,000+ rows. I am writing some pattern matching code but need to clean up a column before I do so. This boils down to doing a replace-like operation. I tried listing them all out one at a time... Update T_ADDRESS set ADDR_LINEONE = REPLACE(ADDR_LINEONE,' southeast ',' se ') Update T_ADDRESS set A...

How safe or bad is using BasePage for opening and closing SQL connection?

Hi, I have BasePage.cs class which is being used by other .cs files instead of System.Web.UI.Page (public partial class page : BasePage). I am using it for opening and closing SQL connections to make sure every SQL connection gets closed. Code looks like this { public class BasePage: System.Web.UI.Page { public SqlCon...

INSERT Xml into SQL Server 2008 database

Hello I'm trying to insert some XML data into a table on SQL Server 2008. However I keep getting thrown this error; XML parsing: line 1, character 39, unable to switch the encoding The database column filemeta uses the XML datatype, and I've switch the encoding to UTF-16 which I believe is necessary for adding XML data. INSERT IN...

MySQL - creating a query optimizer add-on

Hi guys! My question quite a general one. I have to create a prototype of a query optimizer for mySQL, that works instead of standard one, or complements it. It doesn't have to be very complicated, at the beginning. But is there a way of turning off the standard optimizer, so that I can check the way how mine works? And what language is...

LINQ to SQL doesn't call DELETE

I am deleting a bunch of records from different tables that are linked with foreign keys. When I call 'SubmitChanges' the following error is received: The DELETE statement conflicted with the REFERENCE constraint FK_PTXProductMap_CustomerProduct". The conflict occurred in database "SOTI", table "dbo.PTXProductMap", column 'Inst...

Object must implement IConvertible?

Getting this after solving a "Error converting data type nvarchar to datetime" error. Using Vb.net/SQL Server 2000 updating a row via a gridview/sqldatasource: Stored Procedure: @ISTag varchar(10), @PCISTag varchar(10), @User varchar(50), @Date_Start datetime, @Date_End datetime, @Status varchar(50), @Cost money, @Notes varchar(500), @...

How i to get the exact match join for the below scenario?

How do i join the below tables TableA TableB TableC TableD ID ID_C ID ID_A Value ID ID ID_C Value 1 1 1 1 a 1 1 1 a 2 1 b 2 1 b in order to get the Result like Result ID ID_B Value ID_C ID_D ...

multiple GROUP BY columns into one column

Products are grouped for inspected and pass/fail on about 20 criteria. They want a report that counts how many of each defect an individual group has. Defect* is varchar(3) and is used to identify which criteria failed. The table has 3 columns for defects and I can return them with something like: SELECT GroupID, Defect1, COUNT(...

Oracle - Convert value from rows into ranges

Are there any techniques that would allow a row set like this WITH base AS ( SELECT 1 N FROM DUAL UNION ALL SELECT 2 N FROM DUAL UNION ALL SELECT 3 N FROM DUAL UNION ALL SELECT 6 N FROM DUAL UNION ALL SELECT 7 N FROM DUAL UNION ALL SELECT 17 N FROM DUAL UNION ALL SELECT 18 N FROM DUAL UNION ALL SE...

Averaging large amounts of data in SQL Server

It is desired to perform averaging calculations on a large set of data. Data is captured from the devices rather often and we want to get the last day's average, the last week's average, the last month's average and the last year's average. Unfortunately, taking the average of the last year's data takes several minutes to complete. I on...

Complicated daily automatic insert query in 2 tables

I have the following tables with their columns (only the relevant columns are listed): Entry EntryID (int/auto-inc) EmployeeNumber (int) JustifyDate (datetime) EntryDate (datetime) Employee EmployeeNumber (int) CoreHourID (int) WorkingFromHome (bit/bool) Hour EntryID (int) InHour (datetime) OutHour (...

How to store and extract XML information from an nvarchar(max) type column, and use it in joins?

Hi, I have a column of type 'nvarchar(max)' that should now hold XML information instead of just a string. Say: col1 has value 'abc' Now it has values, with additional info: <el1>abc</el2> <el2>someotherinfo</el2> Storing the information to the column is fine, since it can still be pushed in as a string. However, extracting the same...

Oracle Timestamp UTC time format problem

CREATE TABLE DIALOGUE_TABLE(EXPIRE_TIME TIMESTAMP); Following code snippet is inside stored proc :- PO_EXPIRETIME :- OUT PARAM of procedure a varchar2 SELECT TO_CHAR(SYS_EXTRACT_UTC(EXPIRE_TIME)) INTO PO_EXPIRETIME FROM DIALOGUE_TABLE; When I run Stored Proc from server using EXEC and print PO_EXPIRETIME time stamp is pr...

Which query seems efficient?

I want to know which of the 2 queries below is faster :- Select s.*, sm.* from tblStudent s Inner Join (SELECT studentId,SUM(marks) As Sum from tblStudentsMarks Group By studentId) as sm on s.StudentID = sm.StudentID; ...or: Select s.studentId, s.Name, SUM(Marks) From tblStudent s...

Syntax error converting datetime from character string.

Getting this error when updating a row via a gridview with a sqldatasource in Vb.net/SQL Server 2000. No matter what input (1/1/2010, blank, etc) I give it I can't seem to get it right. Code before the input is passed to the sp: Dim sqldatenull As DateTime Dim DateVerify As DateTime sqldatenull = DateTime.MaxValue ...

problem with sql query of a Crystal Report

Hi everyone. When I create a new command of a report that looks like that select e.x, a.x, a.y from Table1 t, table2 a where a.z = e.z and a.xx = form1.ComboBox1.Text it generates an error. Is there a way to do it? Thanks ...