sql-server-2005

Flattening hierarchical XML in SQL using the nodes() method

▼魔方 西西 提交于 2020-01-22 12:44:09
问题 I have a Stored Procedure that takes an XML document as a parameter similar in a structure to the following: <grandparent name="grandpa bob"> <parent name="papa john"> <children> <child name="mark" /> <child name="cindy" /> </children> </parent> <parent name="papa henry"> <children> <child name="mary" /> </children> </parent> </grandparent> My requirement is to "flatten" this data so that it can be inserted into a temporary table and manipulated further down the procedure, so the above XML

Flattening hierarchical XML in SQL using the nodes() method

筅森魡賤 提交于 2020-01-22 12:43:46
问题 I have a Stored Procedure that takes an XML document as a parameter similar in a structure to the following: <grandparent name="grandpa bob"> <parent name="papa john"> <children> <child name="mark" /> <child name="cindy" /> </children> </parent> <parent name="papa henry"> <children> <child name="mary" /> </children> </parent> </grandparent> My requirement is to "flatten" this data so that it can be inserted into a temporary table and manipulated further down the procedure, so the above XML

Flattening hierarchical XML in SQL using the nodes() method

◇◆丶佛笑我妖孽 提交于 2020-01-22 12:43:25
问题 I have a Stored Procedure that takes an XML document as a parameter similar in a structure to the following: <grandparent name="grandpa bob"> <parent name="papa john"> <children> <child name="mark" /> <child name="cindy" /> </children> </parent> <parent name="papa henry"> <children> <child name="mary" /> </children> </parent> </grandparent> My requirement is to "flatten" this data so that it can be inserted into a temporary table and manipulated further down the procedure, so the above XML

What is an efficient method of paging through very large result sets in SQL Server 2005?

核能气质少年 提交于 2020-01-22 09:51:27
问题 EDIT: I'm still waiting for more answers. Thanks! In SQL 2000 days, I used to use temp table method where you create a temp table with new identity column and primary key then select where identity column between A and B. When SQL 2005 came along I found out about Row_Number() and I've been using it ever since... But now, I found a serious performance issue with Row_Number() . It performs very well when you are working with not-so-gigantic result sets and sorting over an identity column.

Difference Between Transaction and TransactionScope

我的梦境 提交于 2020-01-22 07:16:08
问题 I am developing an application which communicates with an SQL Server 2005 database to execute some stored procedures. My client demands that all transactions be managed on the C# side and not by SQL Server, and so I am using System.Transactions.TransactionScope when accessing the database. However, I have just seen the System.Transactions.Transaction datatype, and I am confused... What are the main pros/cons of each type? Which one should I use? Please note that I must also use Enterprise

Difference Between Transaction and TransactionScope

有些话、适合烂在心里 提交于 2020-01-22 07:15:26
问题 I am developing an application which communicates with an SQL Server 2005 database to execute some stored procedures. My client demands that all transactions be managed on the C# side and not by SQL Server, and so I am using System.Transactions.TransactionScope when accessing the database. However, I have just seen the System.Transactions.Transaction datatype, and I am confused... What are the main pros/cons of each type? Which one should I use? Please note that I must also use Enterprise

What's the point to enclose select statements in a transaction?

≯℡__Kan透↙ 提交于 2020-01-22 05:49:05
问题 What's the point to enclose select statements in a transaction? I think select statements are just "GET" data from the database, they don't have chance to rollback something, because you just can't change the data. So, does that to say we never need put select statements in a transaction? Am I right? Thanks. 回答1: You're right: at the standard isolation level, read committed , you do not need to wrap select statements in transactions. Select statements will be protected from dirty reads

stored procedure with wildcard parameters

与世无争的帅哥 提交于 2020-01-21 18:39:42
问题 I've a table create table user (userId varchar(8) not null, userName varchar(8) not null) insert into user select 'NAME1','name1' union all select 'NAME2', 'name2' union all select 'NAME3','name3' I've used stored procedure for wild card parameters as: create procedure wildcard_name @userName nchar(8)= '%' as select * from user where userName like @userName; exec wildcard_name 'n%'; the exec statement is not giving any result,why? 回答1: Did you try running it again? I suspect the exec call is

Profiling statements inside a User-Defined Function

淺唱寂寞╮ 提交于 2020-01-21 15:56:06
问题 I'm trying to use SQL Server Profiler (2005) to track down some application performance problems. One of the calls being made is to a table-valued user-defined function. This function wraps a select that joins several tables together. In SQL Server Profiler, the call to the UDF is logged. However, the select that underlies the UDF isn't being logged at all. Because of this, I'm not getting useful data on which tables & indexes are being hit. I'd like to feed this info into the Database Tuning

SQL Server 2005/2008 Group By statement with parameters without using dynamic SQL?

若如初见. 提交于 2020-01-21 09:56:27
问题 Is there a way to write SQL Server Stored Procedure which to be strongly typed ( i.e. returning known result set of columns ) and having its group statement to be dynamic. Something like: SELECT SUM( Column0 ) FROM Table1 GROUP BY @MyVar I tried the following also: SELECT SUM( Column0 ) FROM Table1 GROUP BY CASE @MyVar WHEN 'Column1' THEN Column1 ELSE Column2 The second statement works only in scenarios where the db types of Column1 and Column2 are the same. If they are not the SQL engine