Advertisement
Advertisement
| 04.14.2008 at 12:13AM PDT, ID: 23319534 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: |
--To create the table
CREATE TABLE [dbo].[EMPLOYEE](
[OBJECT_ID] [int] IDENTITY(1,1) NOT NULL,
[EMPLOYEENAME] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[EMPLOYEESALARY] [int] NULL,
[DEPTID] [int] NULL,
[TMSTAMP] [timestamp]
) ON [PRIMARY]
GO
--Inserting two records to update later
insert into EMPLOYEE(EMPLOYEENAME)
values('ABC')
insert into EMPLOYEE(EMPLOYEENAME)
values('XYZ')
--SP Content
DECLARE @XMLDocPointer INT,
@strXML xml,
@sql VARCHAR(8000)
---CODE TO GET THE NEWLY INSERTED VALUE
SET @strXML ='
<RECORD>
<EMPLOYEE>
<OBJECT_ID>1</OBJECT_ID>
<EMPLOYEENAME>AAAA</EMPLOYEENAME>
<TMSTAMP>0x0000000000000FA7</TMSTAMP>
</EMPLOYEE>
<EMPLOYEE>
<OBJECT_ID>2</OBJECT_ID>
<EMPLOYEENAME>ZZZZ</EMPLOYEENAME>
<TMSTAMP>0x0000000000000FA8</TMSTAMP>
</EMPLOYEE>
</RECORD>
'
EXEC sp_xml_preparedocument @XMLDocPointer OUTPUT, @strXML
SELECT * into #T_TEMP
FROM
OPENXML(@XMLDocPointer,'/RECORD/EMPLOYEE',2)
WITH (OBJECT_ID INT,EMPLOYEENAME VARCHAR(30), EMPLOYEESALARY INT,DEPTID INT,TMSTAMP varchar(50))
SELECT * FROM #T_TEMP
---ERROR IN THE BELOW UPDATE STATMENT WHEN COMPAREING THE TIMESTMAP(IN WHERE CONDITION)
UPDATE EMPLOYEE
SET EMPLOYEE.EMPLOYEENAME=B.EMPLOYEENAME
FROM EMPLOYEE, #T_TEMP B
WHERE EMPLOYEE.OBJECT_ID=B.OBJECT_ID AND EMPLOYEE.TMSTAMP=B.TMSTAMP
select * from EMPLOYEE
--SELECT convert(varbinary(8),TMSTAMP) as t FROM EMPLOYEE
drop table #T_TEMP
|