sql-server-2005

How can I choose the closest match in SQL Server 2005?

…衆ロ難τιáo~ 提交于 2020-01-15 09:57:58
问题 In SQL Server 2005, I have a table of input coming in of successful sales, and a variety of tables with information on known customers, and their details. For each row of sales, I need to match 0 or 1 known customers. We have the following information coming in from the sales table: ServiceId, Address, ZipCode, EmailAddress, HomePhone, FirstName, LastName The customers information includes all of this, as well as a 'LastTransaction' date. Any of these fields can map back to 0 or more

Why date is not taking 13/09/2016

和自甴很熟 提交于 2020-01-15 09:29:51
问题 I am checking condition for 12/09/2016 to 13/09/2016 but it is not showing me data for 13/09/2016 and giving error The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. Here is my query SELECT DISTINCT b.mkey , a.N_UserMkey, cuser_id,isnull(a.N_UserMkey,cuser_id) aa, ISNULL(b.first_name + ' ', '') + ISNULL(b.last_name, '') NAME, convert(varchar,a.U_datetime,103) Action_Date FROM inward_doc_tracking_trl a INNER JOIN user_mst b ON isnull(a.N

Why date is not taking 13/09/2016

无人久伴 提交于 2020-01-15 09:29:17
问题 I am checking condition for 12/09/2016 to 13/09/2016 but it is not showing me data for 13/09/2016 and giving error The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. Here is my query SELECT DISTINCT b.mkey , a.N_UserMkey, cuser_id,isnull(a.N_UserMkey,cuser_id) aa, ISNULL(b.first_name + ' ', '') + ISNULL(b.last_name, '') NAME, convert(varchar,a.U_datetime,103) Action_Date FROM inward_doc_tracking_trl a INNER JOIN user_mst b ON isnull(a.N

Stored procedure - Passing a parameter as xml and reading the data

孤者浪人 提交于 2020-01-15 09:13:58
问题 I have this stored procedure, that reads data from xml and make some inserts ALTER procedure [dbo].[SP_InsertIOs] @iosxml xml AS DECLARE @currRecord int -- parse the records from the XML EXECUTE sp_xml_preparedocument @currRecord OUTPUT, @iosxml BEGIN TRY INSERT INTO SN_IO ( [C1] ,[C2] ,[C3] ) SELECT [C1] ,[C2] ,[C3] FROM OPENXML (@currRecord, 'ios/io', 1) WITH ([C1] [varchar](25) 'C1', [C2] [varchar](25) 'C2', [C3] [varchar](20) 'C3' ) END TRY BEGIN CATCH //SELECT SOME ERROR END CATCH

How to group by less columns than selected

試著忘記壹切 提交于 2020-01-15 09:11:11
问题 I'm facing a problem here (using SQL Server 2005). My SELECT query looks like this: SELECT a.str_column1, b.str_column2, c.date_column3, c.guid_column4 FROM table .... joining the other tables here to get my columns .... GROUP BY a.str_column1, b.str_column2, c.date_column3, c.guid_column4 This will give something like this a.str_column1 b.str_column2 c.date_column3 c.guid_column4 ------------------------------------------------------------------ a1 b1 15/07/2013 someID a2 b2 05/06/2012

Entity Framework deadlock problem

那年仲夏 提交于 2020-01-15 08:43:25
问题 I'm having a strange problem with new Entity Framework for .NET 4 I have a SQL Server 2005 (EXPRESS) database and my service writes data to two tables using entity framework. Let's say tables are TableA and TableB. TableB has foreign key to TableA. In my program there are several threads that writes data in parallel. Each thread has its own ObjectContext. The program creats TableA object and puts it in the object context. Then objects for TableB are created and put to object context. This

Dynamic Columns - SQL Server - Months as Columns

时光总嘲笑我的痴心妄想 提交于 2020-01-15 08:00:14
问题 DB: SQL Server 2005 We have a table that has data in this manner: Project Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec -------------------- ----------- --------------------- --------------------- --------------------- --------------------- --------------------- --------------------- --------------------- --------------------- --------------------- --------------------- --------------------- --------------------- 11-11079 2008 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

SQL Server 2005, Caches and all that jazz

我们两清 提交于 2020-01-15 07:21:28
问题 Background to question: I'm looking to implement a caching system for my website. Currently we're exploring memcache as a means of doing this. However, I am looking to see if something similar exists for SQL Server. I understand that MySQL has query cache which although is not distributed works as a sort of 'stop gap' measure. Is MySQL query cache equivalent to the buffer cache in SQL Server? So here are my questions: Is there a way to know is currently stored in the buffer cache? Follow up

SNIReadSync executing between 120-500 ms for a simple query. What do I look for?

醉酒当歌 提交于 2020-01-15 06:20:08
问题 I am executing a simple query against SQL Server 2005: protected static void InitConnection(IDbCommand cmd) { cmd.CommandText = "set transaction isolation level read uncommitted "; cmd.ExecuteNonQuery(); } Whenever I profile with dotTrace 3.1, it claims that SNIReadSync method is taking between 100 - 500 ms. What sort of things do I need to be looking for in order to get this time down? Thanks! 回答1: I have not tested, but would wonder if you have the same issue if you used a TransactionScope

SQL Query to Get Max Value Based on Different Max Value Given Multiple Records

雨燕双飞 提交于 2020-01-15 05:55:49
问题 I know I can do this with a CTE or another means but I am wondering if this can be done in one select query (no sub-selects). I want to find the most recent crt_ts for the po_nbr and then take the associated id. Note: The id column is not guaranteed to be sequential, I simplified it for this question. Code: create table temp ( id int, po_nbr int, crt_ts datetime ) insert into temp values (20, 100, '09/01/2009') insert into temp values (3, 100, '09/03/2009') insert into temp values (5, 100,