sql-server-2012

How to get Excel to reliably execute sp_executesql from a query table on a worksheet?

早过忘川 提交于 2019-12-24 00:16:47
问题 In MS Excel, if you create a QueryTable with Microsoft Query, and your SQL query cannot be visually presented by Microsoft Query, then you are not allowed to provide parameters for that query. Which is a shame, so there is this awesome technique that allows parameters anyway: {CALL sp_executesql (N'select top (@a) * from mytable', N'@a int', ?)} You provide the query in the ODBC CALL form and it works with parameters. Unless it does not. While on some computers it works flawlessly, on other

I need to remove leading zeros after a decimal point

痴心易碎 提交于 2019-12-24 00:16:37
问题 this is my first time posting here and I am a basic SQL user and need help. I have a varchar column that stores data like below: Year.Docid 2007.000000001 2007.000000002 2007.000000003 2007.000000004 2007.000000005 2007.000000006 I need to join this data to another table that does not have all the zeros after the decimal, can someone please show me how to get the data to look like below: Year Docid 2007.1 2007.2 2007.3 2007.4 2007.5 2007.6 I am using MICROSOFT SQL SERVER 2012 回答1: If the

Query to find the time difference between successive events

谁说胖子不能爱 提交于 2019-12-23 23:05:40
问题 Goal: Return a dataset showing time differences between successive events of the same type Table Structure: CREATE TABLE [dbo].[Event]( [EventID] [int] IDENTITY(1,1) NOT NULL, [JobID] [int] NOT NULL, --FK to Job Table [LastRun] [datetime] NOT NULL, [LastRunEnd] [datetime] NULL, [LastRunResult] [int] NOT NULL, --FK to Result ) ON [PRIMARY] --Event ID is PK Since the data comes from sequential events, LastRun will always increase for each job. LastRunEnd could be null if the process that

SSIS DB2-> SQL Server data migration issue (Timestamp -> DateTime2)

﹥>﹥吖頭↗ 提交于 2019-12-23 21:18:35
问题 we are trying to transfer data from DB2 -> SQL Server 2014 database. When using SSIS to transfer data between tables, the timestamp -> datetime2 is failing due to data type mismatch. Found couple of links related to that, but not sure if they have the source db2 Timestamp column data converted to string format before applying those conversions or data is coming in as Timestamp type and those conversions could still work? please share how to handle this Timestamp -> Datetime2 mismatch in SSIS.

a connection cannot be made to redirector. Ensure that 'sql browser' service is running

狂风中的少年 提交于 2019-12-23 20:25:50
问题 So Im trying this sql server 2012, and I cant open any ssis package due to this error a connection cannot be made to redirector. Ensure that 'sql browser' service is running my Sql Browser is running for sure, I tried changing it under local service, local system and network, still no result yet, any help would be appreciated Thanks 回答1: This error seems to related only to named instances. The reason is SQL client is not able to resolve instance because SQL client has no access SQL Browser

Case-insensitive primary key of type nvarchar where ß != ss

时间秒杀一切 提交于 2019-12-23 20:00:27
问题 This question "Need a case insensitive collation where ss != ß" solves it for varchar type column, but mine has to be nvarchar . As far as I can gather, SQL_Latin1_General_Cp437_BIN differentiates between ß and ss . But it is also case-sensitive. Mine is a primary key column which also needs to be case INsensitive: I need e.g. weiß / Weiß to be considered equal, and also weiss / Weiss , but NOT weiß / weiss nor Weiß / Weiss nor weiß / Weiss etc. I've searched a lot for this, and is it really

Why are these SQL Server statistics outdated, when it's set to auto-update?

倖福魔咒の 提交于 2019-12-23 19:24:00
问题 We have a SQL Server 2012 instance, with auto-statitics set to ON for the DB: But then i ran a query to check some statistics, and some haven't been updated in a while: Why is this the case? Is there a rule to whether SQL Server updates statistics that haven't been triggered by these indexes? Do i need to care? How do i know if i need to update them, or if they are causing performance issues for me? Thanks! 回答1: Even though you set Auto update statistics to true, they will update only when a

SQL Server Default value for columns

拥有回忆 提交于 2019-12-23 18:13:49
问题 When you use default value for a column in SQL Server Management Studio table designer, SSMS change your default and stand Parenthesis around of that (In all editions and all versions of SQL Server). For example if you set 0 as default value, this default changed to (0) . I don't know why sql server use parenthesis, and is there a practical reason. Thanks in advance. 回答1: There are certain types of objects, such as DEFAULT s and CHECK constraints that SQL Server doesn't store the original,

Fast way to “flatten” hierarchy table?

允我心安 提交于 2019-12-23 17:57:47
问题 I've got a very huge table with hierarchy which can not be modified. Nodes in the table have an Id , ParentId , a Level and some data. The Level means that node with level N can be a child not only for level N-1 but also for level N-2 , N-3 etc. The good news are that the number of levels is limited - there are only 8 of them. Level 1 is on the top of the hierarchy and level 8 is the end of it. And now I need to flatten that table with respect to the place of the levels. The result should be

How do I drop a table column in SQL Server 2012? [closed]

坚强是说给别人听的谎言 提交于 2019-12-23 17:11:55
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I wish to drop a table column in SQL Server 2012, without affecting other columns in the table (and their data). How can I do this? Is