sql-server-2008-r2

SQL string manipulation to add xml nodes

大兔子大兔子 提交于 2019-12-11 05:49:23
问题 I am using sql 2008R2, The table is having xml column like- <New> <From> <Scale>Tony</Scale> <ScaleName>Name</ScaleName> </From> </New> <New> <From> <Scale>Tom</Scale> <ScaleName>Name</ScaleName> </From> </New> <New> <From> <Scale>Seven</Scale> <ScaleName>Height</ScaleName> </From> </New> <New> <From> <Scale>Ten</Scale> <ScaleName>Height</ScaleName> </From> </New> <New> <From> <Scale>***XXX***</Scale> <ScaleName>Height</ScaleName> </From> </New> .......so on I need to write a SQL which can

“SQLExpress database file auto-creation error” but DefaultConnect pointing at SQL Server 2008 R2

删除回忆录丶 提交于 2019-12-11 05:42:11
问题 I am using Visual Studio 2012 to create an MVC4 Internet application. I've moved away from Entity Framework and I am now using a local install of SQL Server 2008 R2. I changed my connection string to point at my local SQL Server instance: <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=NotesBoard;Integrated Security=SSPI;" providerName="System.Data.SqlClient" /> </connectionStrings> There are no other connection strings in my project. This

Using a stored procedure containing dynamic SQL to create a report in C# (Report viewer)

南楼画角 提交于 2019-12-11 05:37:23
问题 I have a SQL Server stored procedure that I want to use to create a report in my application (c#). Because the table in the procedure is dynamically created I am having trouble using it to create a report. How can I use this procedure to create a report in my application? I am using VS2010, SQL Server 2008 R2 I created a dataset in VS but not sure how to use it from there. The report wizard cannot use the dataset I created. I gave thought to somehow using this to create a view and then

Getting Request Timeout sometimes from only one SP?

試著忘記壹切 提交于 2019-12-11 05:04:52
问题 I have a lot of stored procedures. But I am only getting Request Timeout sometimes only for this SP ? ALTER PROCEDURE [dbo].[Insertorupdatedevicecatalog] (@OS NVARCHAR(50) ,@UniqueID VARCHAR(500) ,@Longitude FLOAT ,@Latitude FLOAT ,@Culture VARCHAR(10) ,@Other NVARCHAR(200) ,@IPAddress VARCHAR(50) ,@NativeDeviceID VARCHAR(50)) AS BEGIN SET NOCOUNT ON; DECLARE @TranCount INT; SET @TranCount = @@TRANCOUNT; DECLARE @OldUniqueID VARCHAR(500) = ''-1''; SELECT @OldUniqueID = [UniqueID] FROM

Dynamic pivot table

*爱你&永不变心* 提交于 2019-12-11 04:58:15
问题 I have the following table with the details as shown below in the example. Example : Table: test create table test ( cola varchar(10), colb varchar(10), colc varchar(10) ); Insertion : insert into test values('111','222','A1'); insert into test values('111','333','A2'); insert into test values('111','344','A3'); insert into test values('111','444','A4'); insert into test values('767','222','A1'); insert into test values('767','333','A2'); insert into test values('767','344','A3'); insert into

Slow running query on my machine only

限于喜欢 提交于 2019-12-11 04:54:29
问题 I'm running a simple select * from table query against Microsoft SQL Server 2005. The table has about 41000 records with a PK clustered index and I'm using windows integrated authentication. When I run this on my machine using Microsoft SQL Server Management Studio the query completes in about 1h45m. I have tried swithing from grid to text output, running it from command line using SQLCMD also tried ececuting DBCC USEROPTIONS , DBCC DROPCLEANBUFFERS , DBCC FREEPROCCACHE prior the query...

How To change backup path in sql server agent

久未见 提交于 2019-12-11 04:47:29
问题 i want to change my backup location of sql server 2008 r2 ,i am using sql server agent to do backup job ,now the drive is full i want to make the backup into other drive.please provide me the steps how to resolve this issue 回答1: Go to Management>Maintenance Plan> Then select the plan and change the destination auto folder path from the property window 来源: https://stackoverflow.com/questions/23089219/how-to-change-backup-path-in-sql-server-agent

fastest way to find non-matching ids from two tables

我的梦境 提交于 2019-12-11 04:29:48
问题 I have base table with 1000 values. and second temporary table with 100 values. I need to compare them by guids and return only those rows from second table that do not exist in first table. I need the fastest performance solution for that. Thanks! 回答1: The classic left join/isnull test select A.* from secondTbl A left join firstTbl B on A.guid = B.guid WHERE B.guid is null 回答2: SELECT * FROM Table2 WHERE NOT EXISTS (SELECT 'x' FROM table1 where table1.field= table2.field) http://weblogs

Find chain of columns values

假如想象 提交于 2019-12-11 04:29:17
问题 Table: create table tbl_test ( col1 int, col2 int ); Records: INSERT INTO tbl_test VALUES(111,112), (112,113), (113,114), (114,111), (115,116), (117,118), (118,119), (111,130), (120,121), (122,123), (123,111), (124,111); Query : I want to find the complete chain col1 and col2 in the form of 111->112->113->114->111 (This is complete chain because it starts with 111 and end with 111 ). Expected Output 2: col1 col2 ------------- 111 112 112 113 113 114 114 111 回答1: There are more details here in

Trouble with a CASE statement in a sql server stored procedure

守給你的承諾、 提交于 2019-12-11 04:07:30
问题 I have just started using stored procedures in sql server and have been getting on reasonably well, but I have now come across a problem I can't understand. I have searched for an answer, but to be honest I am not sure I am asking the right question. My sp is: ALTER PROCEDURE [FindName] @Square nvarchar(100) = null, @Location nvarchar(100) = null, @Name nvarchar(100) = null, @NormalizedName nvarchar(100) = null, @SharedLand int = 0, @FieldNumber int = 0, @Description nvarchar(255) = null,