sql-server-2012

Why checksum() returns the same value for different string

泪湿孤枕 提交于 2020-01-11 08:30:52
问题 The following SQL and its result shows the different string got the same checksum result. Why? select str , binary_checksum(str) binary_checksum, checksum(str) checksum, hashbytes('md5', str) md5 from ( values ( '2Volvo Director 20'), ( '3Volvo Director 30'), ( '4Volvo Director 40') ) t ( str ) str binary_checksum checksum md5 ------------------ --------------- ----------- -------------------------------------------- 2Volvo Director 20 -1356512636 -383039272 0xB9BD78BCF70FAC36AF14FFF589767278

This simple code produces deadlock. Simple Example Program included

纵饮孤独 提交于 2020-01-11 07:11:29
问题 Code, notice the order of the values is different. So it alternates between locking rows: static void Main( string[] args ) { List<int> list = new List<int>(); for(int i = 0; i < 1000; i++ ) list.Add( i ); Parallel.ForEach( list, i => { using( NamePressDataContext db = new NamePressDataContext() ) { db.ExecuteCommand( @"update EBayDescriptionsCategories set CategoryId = Ids.CategoryId from EBayDescriptionsCategories join (values (7276, 20870),(240, 20870)) as Ids(Id,CategoryId) on Ids.Id =

Can't get SQL Server to start or connect to my local database engine through SSMS

不打扰是莪最后的温柔 提交于 2020-01-10 18:18:48
问题 SQL Server has been working fine but since Friday I have not been able to connect to the database engine in SSMS. This coincided with my having to power the laptop off during a Windows update because it appeared to be hanging (I don't know if these two are related). Since then I have: Gone back to a restore point before the failed update Removed SQL Server 2008 from my machine Installed SQL Server 2012 onto my machine. This failed during the load Removed everything that was labelled SQL

Can't get SQL Server to start or connect to my local database engine through SSMS

与世无争的帅哥 提交于 2020-01-10 18:17:50
问题 SQL Server has been working fine but since Friday I have not been able to connect to the database engine in SSMS. This coincided with my having to power the laptop off during a Windows update because it appeared to be hanging (I don't know if these two are related). Since then I have: Gone back to a restore point before the failed update Removed SQL Server 2008 from my machine Installed SQL Server 2012 onto my machine. This failed during the load Removed everything that was labelled SQL

I am getting Status as “Not Started” in installing setup files step while installing SQL Server 2012 Advanced edition

狂风中的少年 提交于 2020-01-10 05:44:05
问题 The Progress bar is looping infinitely without any progress ![Error Image]: http://i.stack.imgur.com/jWfLp.png 来源: https://stackoverflow.com/questions/38916894/i-am-getting-status-as-not-started-in-installing-setup-files-step-while-instal

Replace first occurrence of substring in a string in SQL

喜欢而已 提交于 2020-01-09 03:49:45
问题 I have to fetch data from a @temp table which has something like "or ccc or bbb or aaa" I want to replace the first occurrence into space to get something like this " ccc or bbb or aaa". I am trying stuff and replace but they don't seem to get me the desired result What I have tried: DECLARE @stringhere as varchar(500) DECLARE @stringtofind as varchar(500) set @stringhere='OR contains or cccc or ' set @stringtofind='or' select STUFF('OR contains or cccc or ',PATINDEX('or', 'OR contains or

How to write dynamic query columns into rows in SQL Server?

人盡茶涼 提交于 2020-01-07 08:09:31
问题 I have a question about in SQL Server: how to combine 4 columns into 1 column in a query. Table: emp empid | addr | sal | doj ------+------+-----+------------ 1 | hyd | 10 | 10-01-1990 2 | del | 20 | 12-03-1999 1 | pune | 50 | 12-03-2017 Based on above data I want output like below empid | empvalues ------+--------------- 1 | hyd 1 | 10 1 | 10-01-1990 2 | del 2 | 20 2 | 12-03-1999 1 | pune 1 | 50 1 | 12-03-2017 I tried with a query like this: select empid, cast (addr as varchar(100)) as

Performance issue in Dynamic Dropdown Search list in excel

谁说胖子不能爱 提交于 2020-01-07 04:34:08
问题 I have created dropdown list which gives suggestions from existing data (like google search). I have followed the steps mentioned in the link to get the expected result. I have changed the process to VBA Code since the column range that has data can increase in time (Formula will be inserted for a range dynamically when a new entry is added). Now the problem is since the column have more than 20 000 rows it takes more time to display the suggestions when a key is pressed. I need to get data

SQL Server job activity (job failed but history records in job activity still showing 'running' status )

不打扰是莪最后的温柔 提交于 2020-01-07 03:06:23
问题 I am checking one SSIS job execution report, which shows me the below report: The most recent one succeeded, but when you take a look at ID:217583, it is still running and never finished (duration keeps increasing), and when I check the job activity in sql server agent, that execution should failed before, the reason why I said that was because the start time matched. Here is the job history in sql server agent : So I assume this job execution failed but for some mystery reason, it still

Using COUNT and Return Percentage Against SUM of Records

假如想象 提交于 2020-01-06 21:38:48
问题 Pretty simple question I suppose, but I can't find the answer on here! I am trying to calculate the volume of records based on a WHERE clause, as well as return a percentage of those records based on the same where clause. The percentage would be calculated against the total amount of records in the database. For example, I count all my records that meet "MyCondition": SELECT COUNT(*) FROM [MyTable] WHERE Condition='MyCondition' This works fine. However, how does one take that count, and