Click here to Skip to main content
15,887,380 members
Home / Discussions / Database
   

Database

 
GeneralRe: help me to write procedure Pin
nelsonpaixao13-Jul-08 15:12
nelsonpaixao13-Jul-08 15:12 
GeneralRe: help me to write procedure Pin
amistry_petlad13-Jul-08 17:58
amistry_petlad13-Jul-08 17:58 
Questiondecimal not show zero [modified] Pin
tai-fun12-Jul-08 3:38
tai-fun12-Jul-08 3:38 
AnswerRe: decimal not show zero Pin
leoinfo12-Jul-08 7:07
leoinfo12-Jul-08 7:07 
Questionrow to column in sql Pin
ravindra_ee24811-Jul-08 19:58
ravindra_ee24811-Jul-08 19:58 
AnswerRe: row to column in sql Pin
Vimalsoft(Pty) Ltd13-Jul-08 15:55
professionalVimalsoft(Pty) Ltd13-Jul-08 15:55 
QuestionMail Triggering in SQL_Server Problem Pin
sabaMCA11-Jul-08 13:43
sabaMCA11-Jul-08 13:43 
AnswerRe: Mail Triggering in SQL_Server Problem Pin
Vimalsoft(Pty) Ltd12-Jul-08 11:11
professionalVimalsoft(Pty) Ltd12-Jul-08 11:11 
QuestionMail Triggering in SQL_Server Problem Pin
sabaMCA11-Jul-08 13:42
sabaMCA11-Jul-08 13:42 
QuestionHow to store stored proc results to a temp table Pin
DotNetXenon11-Jul-08 10:52
DotNetXenon11-Jul-08 10:52 
AnswerRe: How to store stored proc results to a temp table Pin
Vimalsoft(Pty) Ltd12-Jul-08 11:17
professionalVimalsoft(Pty) Ltd12-Jul-08 11:17 
GeneralSQL Server connection timeout [modified] Pin
dlarkin7711-Jul-08 3:44
dlarkin7711-Jul-08 3:44 
GeneralRe: SQL Server connection timeout Pin
Simon P Stevens11-Jul-08 3:48
Simon P Stevens11-Jul-08 3:48 
GeneralRe: SQL Server connection timeout Pin
SimulationofSai11-Jul-08 4:07
SimulationofSai11-Jul-08 4:07 
GeneralRe: SQL Server connection timeout Pin
dlarkin7711-Jul-08 4:26
dlarkin7711-Jul-08 4:26 
GeneralRe: SQL Server connection timeout Pin
Member 9611-Jul-08 5:46
Member 9611-Jul-08 5:46 
GeneralRe: SQL Server connection timeout Pin
Tomz_KV11-Jul-08 5:48
Tomz_KV11-Jul-08 5:48 
QuestionSystem IP in Stored Procedure Pin
Member 400849210-Jul-08 18:51
Member 400849210-Jul-08 18:51 
AnswerRe: System IP in Stored Procedure Pin
N a v a n e e t h10-Jul-08 22:46
N a v a n e e t h10-Jul-08 22:46 
AnswerRe: System IP in Stored Procedure Pin
DerekFL11-Jul-08 4:50
DerekFL11-Jul-08 4:50 
QuestionInserting data into xml column Pin
DerekFL10-Jul-08 9:45
DerekFL10-Jul-08 9:45 
AnswerRe: Inserting data into xml column Pin
leoinfo10-Jul-08 16:31
leoinfo10-Jul-08 16:31 
WOW! A lot of code you put there ...

Try delete all the code and replace it with the block bellow Smile | :)
I don't know what are you using @AuName for, but I'm not kidding, everything you posted can be replaced by this:

/******* START COPY *******/ ;
;WITH XMLNAMESPACES ('uri1' as media, 'uri2' as live) 
UPDATE dbo.DataFeed 
SET items = ( 
		SELECT RTRIM(Title) AS 'media:title' 
		, [Description] AS 'media:description' 
		, Url AS 'live:link' 
		, DateCreated AS 'media:pubdate' 
		, thumbnail AS 'media:thumbnail' 
		FROM dbo.Videos 
		WHERE dbo.Videos.AuthorId = dbo.DataFeed.AuthorId 
		FOR XML PATH('item'), ROOT('root') 
) ;
/******* END COPY *******/ ;





Also, check the below example that I played with, maybe one of the following code styles suits you better:

/* SOURCE TABLE */
CREATE TABLE #T(id int IDENTITY(1,1), name nvarchar(10)); 
INSERT INTO #T (name) SELECT 'Smith';  
INSERT INTO #T (name) SELECT 'Yana'; 
INSERT INTO #T (name) SELECT 'Jane'; 
INSERT INTO #T (name) SELECT 'Mike'; 


CREATE TABLE #D(pk int, dsc xml); 
INSERT INTO #D (pk, dsc) SELECT 1, NULL; 
INSERT INTO #D (pk, dsc) SELECT 2, NULL; 

SELECT 'D:EMPTY', * FROM #D; 

/*STYLE 1 - USING XML VARIABLE*/; 

DECLARE @xmlOUT XML; 

;WITH XMLNAMESPACES ('uriA1' as media, 'uriA2' as live) 
SELECT @xmlOUT = ( 
   SELECT id as 'media:id1' 
         ,name AS 'live:name' 
   FROM #T 
   FOR XML PATH('item'), ROOT('root') 
);  

 
UPDATE #D 
SET dsc =  @xmlOUT 
WHERE pk = 1; 

SELECT 'D:PK1', * FROM #D; 

/*STYLE 2 - USING DIRECT UPDATE*/; 
;WITH XMLNAMESPACES ('uriB1' as media, 'uriB2' as live) 
UPDATE #D  
SET dsc = ( 
    SELECT  id as 'media:id2' 
          , name AS 'live:name' 
    FROM #T  
    FOR XML PATH('item'), ROOT('root') 
    ) 
WHERE pk = 2 ; 
 
SELECT 'D:PK2', * FROM #D; 



CREATE TABLE #X(pk int, dsc xml); 
INSERT INTO #X (pk, dsc) SELECT 1, NULL; 
INSERT INTO #X (pk, dsc) SELECT 2, NULL; 
INSERT INTO #X (pk, dsc) SELECT 3, NULL; 
INSERT INTO #X (pk, dsc) SELECT 4, NULL; 

SELECT 'X:EMPTY',  * FROM #X; 

/*STYLE 3 - USING DIRECT UPDATE*/; 
;WITH XMLNAMESPACES ('uriB1' as media, 'uriB2' as live) 
UPDATE #X  
SET #X.dsc = ( 
    SELECT  #T.id as 'media:id2' 
          , #T.name AS 'live:name' 
    FROM #T  
	WHERE #T.id = #X.pk 
    FOR XML PATH('item'), ROOT('root') 
    );  

SELECT 'X:FINAL',  * FROM #X; 

DROP TABLE #D; 
DROP TABLE #T; 
DROP TABLE #X; 

JokeRe: Inserting data into xml column Pin
leoinfo10-Jul-08 16:39
leoinfo10-Jul-08 16:39 
GeneralRe: Inserting data into xml column Pin
DerekFL11-Jul-08 4:18
DerekFL11-Jul-08 4:18 
QuestionDTS Stopped working after motherboard change Pin
FrankLepkowski10-Jul-08 8:33
FrankLepkowski10-Jul-08 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.