sql-server-2008-r2

TCP Provider: The semaphore timeout period has expired

谁说胖子不能爱 提交于 2019-12-22 12:19:53
问题 In Sql Server2008 R2 and Windows Server 2008R2, when I start Replication I have this error: TCP Provider: The semaphore timeout period has expired Please help me to solve it. 回答1: in order to fix the error: System.IO.IOException: The semaphore timeout period has expired. ​Solution​ I have done below NIC changes to resolve this error. Open the Network and Sharing Center. Right click on Ethernet Adapter>>Properties Select Client for Microsoft Networks Click on Configure Tab Click on Advanced

SQL Server optimistic locking - Returning changed timestamp value

六眼飞鱼酱① 提交于 2019-12-22 10:48:35
问题 I have an update stored procedure that implements optimistic locking. The stored procedure looks like this: ALTER PROCEDURE [dbo].[usp_Test] @Id AS char(2), @recordTimestamp as timestamp ... BEGIN UPDATE XY .. WHERE ((Id = @Id) AND (recordTimeStamp = @recordTimestamp)) if @@rowcount = 0 begin RAISERROR ('this row was changed by another user', 18, 1) end SELECT timeStamp from XY where Id = @Idend Is there a simpler way to return the new timestamp? I would really like to avoid the SELECT

SQL Server 2008 R2 standard missing “Audits” folder in SSMS?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 10:16:39
问题 I will pre-cursor this with the fact that I am NOT a DBA! I am trying to set up auditing on an SQL Server 2008 R2 Standard edition, but the Audits folder is missing from the Security section. Is this a version issue associated with the "fine-grained auditing" that is only in the Enterprise and DataCenter editions? Any help is greatly appreciated! 回答1: According to Features Supported by the Editions of SQL Server 2008 R2 auditing is only available in 2008 / 2008 R2 Enterprise / Datacenter.

Better way to check condition instead of repeated Case When

心不动则不痛 提交于 2019-12-22 09:28:55
问题 This is my Tables: [Member]: { [Id], [UserId], [UserName], [Email], [Status_Id], [MemberType_Id] } [CustomerProfile] : { [Id], [Member_Id], [FirstName], [LastName], [SSN], [Gender], [PostalCode],[City_Id], [Address]} [DealerProfile]: { [Id], [Member_Id], [FirstName], [LastName], [SSN], [Gender], [StoreName], [PostalCode], [City_Id], [Address] } [ManagerProfile] { [Id], [Member_Id], [FirstName], [LastName], [SSN], [Gender] } [City]: { [Id], [Title], [Province_Id] } So I need to create a full

SQL Increment count on repeat values?

醉酒当歌 提交于 2019-12-22 08:38:25
问题 Not sure how to ask this question, I'm not looking for the total count of a value in a column, rather I want to incrementally count repeat values. For example: If my table looks like this: 1, ken 2, ken 3, adam 4, ken 5, adam 6, dan I want to add a column during my select that tags duplicates with an incremental number like this: 1, ken, 1 2, ken, 2 3, adam, 1 4, ken, 3 5, adam, 2 6, dan, 1 回答1: You can do this via ROW_NUMBER() with a PARTITION on your second column, ordering by the first:

Must declare the scalar variable error for stored procedure

你。 提交于 2019-12-22 08:22:28
问题 I have following stored procedure: CREATE procedure validateLogin ( @password varchar(200), @username varchar(100), @IpAddress varchar(100) ) AS BEGIN Declare @qry varchar(max), @LockedIp varchar(max), @LockedTime DateTime, @TimeDifference int; set @qry = 'select IdUser, UserName, FirstName, LastName, idOrg, Users.idRole, Roles.Title as [Role], Allowed_IP from Users, Roles where Users.idRole = Roles.idRole and lower(UserName) = @username and [password] = @password' ; select @LockedIp = isnull

Fully matching sets of records of two many-to-many tables

隐身守侯 提交于 2019-12-22 07:58:13
问题 I have Users , Positions and Licenses . Relations are: users may have many licenses positions may require many licenses So I can easily get license requirements per position(s) as well as effective licenses per user(s). But I wonder what would be the best way to match the two sets ? As logic goes user needs at least those licenses that are required by a certain position. May have more, but remaining are not relevant. I would like to get results with users and eligible positions. PersonID

Spatial index slowing down query

…衆ロ難τιáo~ 提交于 2019-12-22 05:15:41
问题 Background I have a table that contains POLYGONS/MULTIPOLYGONS which represent customer territories: The table contains roughly 8,000 rows Approximately 90% of the polygons are circles The remainder of the polygons represent one or more states, provinces, or other geographic regions. The raw polygon data for these shapes was imported from US census data. The table has a spatial index and a clustered index on the primary key. No changes to the default SQL Server 2008 R2 settings were made. 16

How do I listen for SQL Server database changes

浪尽此生 提交于 2019-12-22 04:49:09
问题 Using .Net 4.0 and SQL Server 2008 R2 I have been looking into utilizing SqlDependency / SqlNotifications for monitoring some database structures. Is the best process / practice for this to utilize the SqlDependency / SqlNotifications with SQL Server Service broker? Are folks using other methods to accomplish a similar task? I could always poll for changes, but I would rather not have to do that. On the other hand I don't want to introduce a complex scenario into our existing environment

Nested Transactions in .NET

主宰稳场 提交于 2019-12-22 04:46:12
问题 How can I perform the equivalent of this? My understanding is that this is impossible with TransactionScopes but I'd like to accomplish the equivalent in some other way: Business Logic class: public bool Bar() { try { using (var tsWork = new TransactionScope()) { ComplicatedDataImportCode(somedata); FlagRecordInDatabaseAsImported(); // this is the same record that's modified in the catch tsWork.Complete(); return true; } catch (DuplicateDataException err) { // if we got here, the above