sql-server-2008-r2

EntityFramework : Calling ToList() on IQueryable with ~11.000 records takes 10 seconds

浪尽此生 提交于 2019-12-10 10:57:03
问题 I want to return a relatively large number of records from SQL Express 2008 R2 server, via EntityFramework 4 through WCF service to a WCF client. My test table contains around 11.000 records at the moment. The LINQ query is as simple as this: Database DB = new Database(); // create object context var retValue = DB.Entities.Persons .Include("District") .Include("District.City") .Include("District.City.State") .Include("Nationality") return retValue.ToList(); This takes about 10 seconds to

Copy missing rows from one table to another in sql server with stored procedure

我是研究僧i 提交于 2019-12-10 10:49:34
问题 I have to tables in different databases (on the same server) that are identical. I need to transfer the data rows from the left database table to the right database table, but I only want to transfer the rows that aren't in the right database table already. Is there a neat way of doing this? Im using SQL Server 2008 R2 回答1: Assuming that you can uniquelly identify a row with column id : insert into databasename..tablename select * from datababasename2..tablename2 where id not in (select id

Saving results from Execute SQL Task to Excel

旧城冷巷雨未停 提交于 2019-12-10 10:48:25
问题 I'm trying to develop a package in SSIS. The package's logic is relatively simple: Execute a Query and save the result set in an excel spreadsheet. Hence I first tried to create an architecture as shown below:- The problem I'm facing is that the query makes use of temporary tables and OLE DB Source doesn't seem to be able to parse queries containing temp tables(#table-names). So i tried using a Execute SQL task in my control flow. This seems to be able to execute this query. But now I want to

why ss round to nearest minute that will change day

大城市里の小女人 提交于 2019-12-10 10:47:54
问题 I am using sql server 2008 R2 and due to one problem i am able to know that smalldatetime round ss to nearest minute . here is content from MSDN . ss is two digits, ranging from 00 to 59, that represent the second. Values that are 29.998 seconds or less are rounded down to the nearest minute, Values of 29.999 seconds or more are rounded up to the nearest minute. Now i face one problem due to this, that i have parameter type in my storedproceduer is smalldatetime when i pass '2014-03-23 23:59

Sql Query to get the record what has the max id number for each type

一个人想着一个人 提交于 2019-12-10 09:53:53
问题 I have a table in sql server. It has a pid field used as a primary key and a field called deviceid that has a device name. example: pid deviceid field3 field4 1 Device1 test test 2 Device2 test2 test2 3 Device1 test3 test3 4 Device2 test4 test4 For a query, i need select * from the table where the pid is the max per device. Example result: pid deviceid field3 field4 3 Device1 test3 test3 4 Device2 test4 test4 Im not sure how do do this. Any one have any ideas? The closest i got was: Select

changing bar fill colours in ssrs chart

你离开我真会死。 提交于 2019-12-10 09:45:18
问题 SO Post Current I've got 5 bars in my RS chart - in the future there might be 7 bars or 17 bars or 27 bars! With a couple of bars I can have an expression like this: =iif(Fields!Market.Value = "Spain" ,"Gold" ,iif (Fields!Market.Value = "Denmark" , "Gray" , iif(Fields!Market.Value = "Italy" , "Blue" , "Purple" ) ) ) If I can't predict how many countries will be included + I'd rather not have to hard code in "Green", "Red" etc how do I change the expression? I've tried this but it is erroring:

Understand Unicode and code pages in SQL Server collations

梦想与她 提交于 2019-12-10 09:43:41
问题 Why all SQL Server 2008 R2 collations are associated to a code page. Are all collations unicode ? How to choose a collation when our database is used by several languages using differents code pages ? Thank you. 回答1: CHAR vs. NCHAR (ie. Non-Unicode vs. Unicode) defines the character storage encoding. Collations define... collation (ie. sort order and comparison rules). They are different concepts, although often confused. The confusion stems from the fact that the client tools use the

Get records based on Current Date and Configured Data

微笑、不失礼 提交于 2019-12-10 09:32:13
问题 I am working on automating the SMS sending part in my web application. SQL Fiddle Link DurationType table stores whether the sms should be sent out an interval of Hours, Days, Weeks, Months. Referred in SMSConfiguration CREATE TABLE [dbo].[DurationType]( [Id] [int] NOT NULL PRIMARY KEY, [DurationType] VARCHAR(10) NOT NULL ) Bookings table Contains the original Bookings data. For this booking I need to send the SMS based on configuration. SMS Configuration . Which defines the configuration for

Populate the number ranges & concatenate with text in the child table

心已入冬 提交于 2019-12-10 09:32:09
问题 Wondering how to build a logic for the below scenario (I am using SQL Server 2008 & above). In TblMaster each record will have a Start value and an End value. Along with that a CharToAdd varchar column as well. If the range says 1 to 3 then in the TblDetails there should be an entry for 1,2,3. Not sure whether I am explaining it effectively so have provided a screenshot with sample input/output as well. Ranges would be anywhere between 5000 to 100000 (max) so performance is a concern as well.

TSQLQuery.FieldByName().AsString -> TStringStream Corrupts Data

丶灬走出姿态 提交于 2019-12-10 05:53:06
问题 I'm using Delphi XE2. My code pulls data from a SQL-Server 2008 R2 database. The data returned is a nvarchar(max) field with 1,055,227 bytes of data. I use the following code to save the field data to a file: procedure WriteFieldToFile(FieldName: string; Query: TSQLQuery); var ss: TStringStream; begin ss := TStringStream.Create; try ss.WriteString(Query.FieldByName(FieldName).AsString); ss.Position := 0; ss.SaveToFile('C:\Test.txt'); finally FreeAndNil(ss); end; end; When I inspect the file