sql-server-2014

Kill only user processes in SQL Server

余生颓废 提交于 2020-05-13 14:20:12
问题 We have users that forget to close their access queries that use our SQL 2014 databases. When this happens it prevents the tables they are accessing from being rebuilt over night. Is there any way to Kill these users and not kill the system processes. From what I've read system processes are not only limited to SPID >50. 回答1: Killing user processes based on spid>=50 seems to be not reliable. From Adam Machanic:Smashing a DMV Myth: session_id > 50 == User Process A recent conversation on an

Error when trying to execute a command in sql server

前提是你 提交于 2020-04-20 18:40:47
问题 I am using SQL Server 2014 and working on creating views from all the user database on to a Test database. The generated sql statement works fine when run from SSMS but when the execute command tries to run it I get the following error message. SQL Query: DECLARE @SQL NVARCHAR(MAX), @QueryStmt NVARCHAR(MAX) SET @SQL = '' SELECT @SQL = @SQL + CHAR(13) + 'USE ' + QUOTENAME([name]) + '; SELECT @QueryStmt = ''USE TestDWH ''+ CHAR(13) + CHAR(10) + ''GO'' + CHAR(13) + CHAR(10) + ''IF EXISTS (SELECT

Error when trying to execute a command in sql server

痴心易碎 提交于 2020-04-20 18:37:29
问题 I am using SQL Server 2014 and working on creating views from all the user database on to a Test database. The generated sql statement works fine when run from SSMS but when the execute command tries to run it I get the following error message. SQL Query: DECLARE @SQL NVARCHAR(MAX), @QueryStmt NVARCHAR(MAX) SET @SQL = '' SELECT @SQL = @SQL + CHAR(13) + 'USE ' + QUOTENAME([name]) + '; SELECT @QueryStmt = ''USE TestDWH ''+ CHAR(13) + CHAR(10) + ''GO'' + CHAR(13) + CHAR(10) + ''IF EXISTS (SELECT

Error when trying to execute a command in sql server

▼魔方 西西 提交于 2020-04-20 18:36:54
问题 I am using SQL Server 2014 and working on creating views from all the user database on to a Test database. The generated sql statement works fine when run from SSMS but when the execute command tries to run it I get the following error message. SQL Query: DECLARE @SQL NVARCHAR(MAX), @QueryStmt NVARCHAR(MAX) SET @SQL = '' SELECT @SQL = @SQL + CHAR(13) + 'USE ' + QUOTENAME([name]) + '; SELECT @QueryStmt = ''USE TestDWH ''+ CHAR(13) + CHAR(10) + ''GO'' + CHAR(13) + CHAR(10) + ''IF EXISTS (SELECT

SQL Server Management Studio 2014: Unable to view stored procedures on Azure SQL Database V12

梦想的初衷 提交于 2020-02-03 09:43:13
问题 I have updated SQL Server Management Studio to the latest version at time of writing - 12.0.4432.0 - this is SP1 with CU3 and additional bug fixes. My Azur SQL Database version is 12.0.2000.8 I can not view any stored procedures through the GUI, when I try I get this error (all other functionality appears to be working normally): TITLE: Microsoft SQL Server Management Studio Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc) For help, click: http://go.microsoft

SQL Server xp_delete_file parameters

假装没事ソ 提交于 2020-01-31 23:00:23
问题 Who can explain list of xp_Delete_file parameters in sql server. I don't find msdn document for this stored procedure. I got script of xp_Delete_file from maintenance plan but didn't understand first parameter. 回答1: Xp_delete_file take five parameters: File Type = 0 for backup files or 1 for report files. Folder Path = The folder to delete files. The path must end with a backslash "\". File Extension = This could be 'BAK' or 'TRN' or whatever you normally use. Date = The cutoff date for what

SQL Server xp_delete_file parameters

人盡茶涼 提交于 2020-01-31 22:59:27
问题 Who can explain list of xp_Delete_file parameters in sql server. I don't find msdn document for this stored procedure. I got script of xp_Delete_file from maintenance plan but didn't understand first parameter. 回答1: Xp_delete_file take five parameters: File Type = 0 for backup files or 1 for report files. Folder Path = The folder to delete files. The path must end with a backslash "\". File Extension = This could be 'BAK' or 'TRN' or whatever you normally use. Date = The cutoff date for what

Increasing the storage of an existing SQL Server RDS instance on AWS

烈酒焚心 提交于 2020-01-30 07:50:27
问题 Is there a way to increase the storage capacity of an existing SQL Server RDS instance on AWS ? AWS documentation says it can't be as per https://aws.amazon.com/premiumsupport/knowledge-center/rds-out-of-storage/ What are other alternatives to achieve this ? How are people dealing with this situation in real time like in the case of production scenario ? 回答1: Its not possible to increase the storage for SQL Server Database on Amazon RDS. http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide

Create missing months dynamically from group on date field [duplicate]

夙愿已清 提交于 2020-01-25 20:34:26
问题 This question already has answers here : SQL select, pad with chronological missing months (3 answers) Closed 4 years ago . In the following SQL i'm trying to insert rows to fill in the missing months in the results. The solution is very close thanks to post SQL select, pad with chronological missing months But yet this code runs gr8 but still have missing months, issue is how to join/union the temp table DECLARE @StartDate DATETIME = dateadd(m,-12,getdate()), @EndDate DATETIME = getdate(),

How to loop statements in SQL Server

不打扰是莪最后的温柔 提交于 2020-01-22 03:31:11
问题 I am new to SQL Server, I am trying to do something as follows. Sample code : SELECT ITEM_ID FROM 'TABLE_NAME_1' WHERE ITEM_STATUS = 'ACTIVE' SET @ITEM_PRICE = (SELECT PRICE FROM 'TABLE_NAME_2' WHERE 'PRODUCT_ID' = 'ITEM_ID') INSERT INTO 'TABLE_NAME_3' (ITEM_ID, PRICE) VALUES (@ITEM_ID, @ITEM_PRICE) The first statement will return multiple rows of ITEM_ID By using the ITEM_ID I need to select the ITEM_PRICE from another table using the second statement By using the third statement, I need to