sql-server-2008-r2

SQL Server 2008R2 Transactional Replication - Move SubscriberDB - Push Subscription

穿精又带淫゛_ 提交于 2019-12-11 06:53:04
问题 SQL Server 2008R2 Transactional Replication - Move SubscriberDB - Push Subscription I have a requirement to move a subscriber database to a new server outside of a system outage i.e. I cannot stop new transaction from loading into the publisher database. So far I have attempted to stop the distribution agent and let all un-replicated commands replicate to the subscriber database at Server1. Then backup and restore the subscriber database to Server2. I have then created a new subscription from

SQL Azure - Could not able to alter column type

空扰寡人 提交于 2019-12-11 06:49:24
问题 Today I created a new table in SQL Azure portal and by default there is an Id INT column. Id ( int , PK , Not Null) When I tried to change it to BIGINT it gave me the following error: An error was encountered while applying the changes.An exception occurred while executing the Transact-SQL statement: ALTER TABLE [dbo].[PerformanceData] ALTER COLUMN [Id] BIGINT NOT NULL. The object 'PrimaryKey_029c7a8d-e6b2-43b8-94f1-98fc5b0115e3' is dependent on column 'Id'. ALTER TABLE ALTER COLUMN Id failed

SQL Server 2008 R2: Matching strings

廉价感情. 提交于 2019-12-11 06:48:45
问题 I have the following table: Table: CREATE TABLE str_matching ( colstr varchar(200) ); Insert data: INSERT INTO str_matching VALUES('5sXYZA1010B') INSERT INTO str_matching VALUES('A1010B') INSERT INTO str_matching VALUES('AMZ103B15K') INSERT INTO str_matching VALUES('B15K') INSERT INTO str_matching VALUES('XC101') INSERT INTO str_matching VALUES('C101') INSERT INTO str_matching VALUES('502KMD1FZ10009L') INSERT INTO str_matching VALUES('FZ10009L') INSERT INTO str_matching VALUES('A9L') INSERT

Database script not executing in SQL Server 2008

坚强是说给别人听的谎言 提交于 2019-12-11 06:38:24
问题 In my SQL Server 2008 R2, I have a database script which generates successfully, but when I am trying to execute that script it only shows Executing query message and nothing happen. I had waited at-least 10 minutes for result but force fully I have to stop executing that query. Note: All other queries are working normally, but only database script is not executing as explained above I don't know what's going on... More details: This thing is not happening on particular DataBase, it is a

If Variable is Blank Then No Where Clause

喜欢而已 提交于 2019-12-11 06:32:34
问题 I am trying to do what the below pseuedo code infers: WHERE CASE WHEN @test <> '' THEN Agent = @test ELSE --no where clause END What is the correct structure for this? 回答1: use OR: select * from yourTable where @test = '' OR Agent = @test if @ test coming with null value (instead of '' ), you must use: select * from yourTable where @test is null OR Agent = @test 来源: https://stackoverflow.com/questions/11528875/if-variable-is-blank-then-no-where-clause

Production Perfomance of using SELECT * statements?

时间秒杀一切 提交于 2019-12-11 06:19:40
问题 Why is the use of SELECT * in production code considered bad practice? Is there any alternative for using in production, or do we need to SELECT every column in the table individually? 回答1: Using SELECT * is a bad practice for a few reasons, at least in the context of SSIS. Selecting all the columns, if you don't need all of them, is a waste of memory and memory is the magic that makes SSIS run fast (or not). Selecting all the columns, if you don't need all of them, will prevent SQL Server

T-SQL Pivot Add Total Row

拥有回忆 提交于 2019-12-11 06:06:33
问题 I have a pivot statement which produces what I need it to except I'd like a "total" row adding to the bottom. Can anyone shed any light please? SELECT TheProvider AS [PC], ISNULL([201204],0) AS [201204], ISNULL([201205],0) AS [201205], -- 2012/13 ISNULL([201206],0) AS [201206], -- 2012/13 ISNULL([201207],0) AS [201207], -- 2012/13 ISNULL([201208],0) AS [201208], -- 2012/13 ISNULL([201209],0) AS [201209], -- 2012/13 ISNULL([201210],0) AS [201210], -- 2012/13 ISNULL([201211],0) AS [201211], --

How can I calculate business date and time from date assigned in SQL

廉价感情. 提交于 2019-12-11 05:59:14
问题 For example we have date 5/4/2017 01:00:00 PM And we have working hours 08:00 to 17:30 in weekdays How should I calculate SLA Date and Time ? Date Assigned :5/4/2017 01:00:00 PM If SLA is 8 Hours from date assigned . The Expiry Date should be Like : 5/5/2017 11:30:00 AM by excluding weekends and non-business hours. 回答1: This is a much more complicated problem then I think you are giving it credit for. There are a number of days and times that will fall outside of working hours that you will

(JDBC) SQL Server connection string: login failed for user ' '

给你一囗甜甜゛ 提交于 2019-12-11 05:58:50
问题 jdbc:sqlserver://localhost:1433;Data Source=(local); Initial Catalog=MarketDataDB; User Id=andrew; Password=mypassword; Above is the connection string I am using to connect to a SQL Server 2008 R2 Express database using JDBC, but this error is produced: Login failed for user ' ' Any ideas? I can successfully connect to the database from within SQL Server Management Studio using the specified username and password. I am using SQL Server authentication 回答1: jdbc:sqlserver://localhost\

Newbie: Cache event-change table with every date

心不动则不痛 提交于 2019-12-11 05:57:18
问题 I have a table of items which change status every few weeks. I want to look at an arbitrary day and figure out how many items were in each status. For example: tbl_ItemHistory ItemID StatusChangeDate StatusID Sample data: 1001, 1/1/2010, 1 1001, 4/5/2010, 2 1001, 6/15/2010, 4 1002, 4/1/2010, 1 1002, 6/1/2010, 3 ... So I need to figure out how many items were in each status for a given day. So on 5/1/2010, there was one item (1001) in status 2 and one item in status 1 (1002). I want to create