sql-server-2012

SQL Query to return records grouped by Week, Month, and Year. Weeks with no records should return 0

社会主义新天地 提交于 2019-12-07 08:15:07
问题 Given the following data: ID CreatedDate ID1 2014-06-04 01:40:56.880 ID8 2014-06-05 00:27:02.403 ID6 2014-06-04 01:51:47.060 ID7 2014-06-05 00:25:35.187 ID4 2014-06-04 01:48:44.157 ID10 2014-06-05 00:28:33.993 ID43 2014-06-16 05:17:18.803 ID72 2014-06-20 04:00:07.733 . . . Etc. I need to write a query that will group records by week, month, and year. A count of the number of records that were created in a particular week needs to be returned. The output should be as follows: Week Month Year

How to escape one or more consecutive rows from table, inoutMode either 1 or 0

情到浓时终转凉″ 提交于 2019-12-07 07:24:24
I have a table My table with result like as below: Id EmpCode CheckInCheckOutDate WorkDate InOutMode 85223 175 2017-10-27 11:20:39.000 2017-10-27 11:20:39.000 0 85832 175 2017-10-27 14:21:21.000 2017-10-27 14:21:21.000 1 85844 175 2017-10-27 14:36:23.000 2017-10-27 14:36:23.000 0 85863 175 2017-10-27 15:21:27.000 2017-10-27 15:21:27.000 1 85878 175 2017-10-27 16:03:46.000 2017-10-27 16:03:46.000 0 86031 175 2017-10-27 18:14:41.000 2017-10-27 18:14:41.000 1 86038 175 2017-10-27 18:34:45.000 2017-10-27 18:34:45.000 0 **86039 175 27.10.2017 18:34:46.000 27.10.2017 18:34:46.000 1 86142 175 2017-10

Dynamic SQL Result INTO Temporary Table

瘦欲@ 提交于 2019-12-07 07:23:41
问题 I need to store dynamic sql result into a temporary table #Temp . Dynamic SQL Query result is from a pivot result, so number of columns varies(Not fixed). SET @Sql = N'SELECT ' + @Cols + ' FROM ( SELECT ResourceKey, ResourceValue FROM LocaleStringResources where StateId =' + LTRIM(RTRIM(@StateID)) + ' AND FormId =' + LTRIM(RTRIM(@FormID)) + ' AND CultureCode =''' + LTRIM(RTRIM(@CultureCode)) + ''' ) x pivot ( max(ResourceValue) for ResourceKey IN (' + @Cols + ') ) p ;' --@Cols => Column Names

msxml3.dll in context sp_OAMethod 'send'

℡╲_俬逩灬. 提交于 2019-12-07 06:05:35
问题 Working code from Win2003 + SQL Server 2005 is not working under Win2012 + SQL Server 2012 sp1. The only ~real solution I found is: I copied C:\Windows\System32\msxml3.dll from a Server 2008 to the same dir on a server 2012. Problem on 2012 server solved, sending with POST and GET working fine. But as I cannot modify server and both msxml3.dll and msxml6.dll are locked - I need to understand what is wrong and apply other way. Code is simple as usual for grabbing soap web service: Declare

what would cause a linked server to return a limited amount of data?

∥☆過路亽.° 提交于 2019-12-07 04:49:47
问题 We are having an issue with a server that we linked to our sql server 2012 instance. The server that we linked through an odbc or oledb connection is Pervasive SQL. Selecting from the linked server this way works as long as the result set is small: select * from linked_server.database..mytable If the result set is more than around 2mb (might be slightly more or less) then we get this error: Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "MSDASQL" for linked server "KSLAP208" reported

Update database feature not working in Publish Web dialog in Visual Studio 2012

╄→尐↘猪︶ㄣ 提交于 2019-12-07 04:06:53
问题 I'm developing an ASP.NET Web Forms application under Visual Studio 2012. I'm using Web Deploy and Publish Web dialog for application deploy. I'm trying to deploy a database schema using the Update database feature. I entered a connection string pointing to remote SQL Server. If I click the "Test connection" button Visual Studio says test connection is succeeded. Then I go to Preview tab and click the Preview database link. And in the opened window I have the message Web deployment task

Create evenly sized groups based on aggregate

强颜欢笑 提交于 2019-12-07 03:56:09
问题 Probably a newbie question, but I'm looking to split our server inventory up into several evenly sized groups based on total database size, and am stumped figuring out how to group them. I think NTILE will work, maybe, but I just can't wrap my head around splitting the groups evenly. My example below is just ordering the servers randomly. I would like the results to be 3 groups of fairly even size (obviously won't be exact). Using SQL Server 2012. Any help is appreciated. Thanks. declare

Check if a linked SQL server is running

送分小仙女□ 提交于 2019-12-07 03:11:42
问题 I am writing a stored procedure which runs SELECT queries on several different linked servers using the 4-dot notation. The problem is, if one of the linked servers is not running, the query fails with error 121 ('The semaphore timeout period has expired') . The other SELECT queries then don't run as this error stops the rest of the query executing. I wanted to check @@ERROR then continue running the other queries. How can I continue running the query if the connection to one of the linked

How to delete all dependent rows

心不动则不痛 提交于 2019-12-07 03:08:28
问题 I have a table A which has primary key column a and it is forigen key to B table(Table B has primary key b and column a).Table B has also a primary key b which forigen key to C table and so on. Now if I want to delete a row from Table A then it wont allow me because its dependent table B and table B is dependent on Table C.So I have to delete a row from C first then B and at last A manually So can anybody please tell me if there is any way to delete directly without going to each table and

SSIS Package Stuck at “Created Execution” Status

孤街浪徒 提交于 2019-12-07 03:04:15
问题 I recently deployed a update to one of my SSIS projects, and ever since the project has failed it's scheduled runs. The SSIS package appears to be stuck at the "Created Execution" status. There are no messages in the reports to explain this issue. I've attempted to redeploy the project, but the results remain the same. I ultimately had to revert to an earlier version of the deployment in order to bring the system back online, but I am now in a position where I can not update the project. I'm