Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Change data with uniqueidentifier

Author  Topic 

ddtopgun
Starting Member

26 Posts

Posted - 2014-06-04 : 04:53:16
hi can anyone help me how to change data with id is uniqueidentifier

using below the code the data can't be updated..


IF @StatementType = 'Update'
BEGIN
UPDATE PC
SET idFactory=(SELECT idFactory FROM Factory WHERE nmFactory=@nmFactory),
idDepartemen=(SELECT idDepartemen FROM Departemen WHERE nmDepartemen=@nmDepartemen),
nmKomputer=@nmKomputer,
nmUser=@nmUser,
Email=@Email,
Jenis=@Jenis,
Procesor=@Procesor,
Frek=@Frek,
Memory=@Memory,
Hdd=@Hdd,
Monitor=@Monitor,
OS=@OS,
Software=@Software,
Statuss=@Statuss
WHERE idPC=CONVERT(varchar(36),@idPC)
--SELECT * FROM PC
END

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-06-04 : 06:22:09
[code]

IF @StatementType = 'Update'
BEGIN
UPDATE PC
SET idFactory=Factory.idFactory,
idDepartemen=Departemen.idDepartemen,
nmKomputer=@nmKomputer,
nmUser=@nmUser,
Email=@Email,
Jenis=@Jenis,
Procesor=@Procesor,
Frek=@Frek,
Memory=@Memory,
Hdd=@Hdd,
Monitor=@Monitor,
OS=@OS,
Software=@Software,
Statuss=@Statuss
FROM
PC as PC
INNER JOIN Factory
ON PC.idFactory = Factory.idFactory
INNER JOIN Departemen
ON PC.idDepartemen=Departemen.idDepartemen
WHERE idPC=CONVERT(varchar(36),@idPC)
AND Factory.nmFactory=@nmFactory
AND Departemen.nmDepartemen=@nmDepartemen
--SELECT * FROM PC
END
[/code]


sabinWeb MCP
Go to Top of Page

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-06-04 : 06:23:23
or:


DECLARE
@idFactory INT
,@idDepartemen INT

SELECT @idFactory = idFactory FROM Factory WHERE nmFactory=@nmFactory
SELECT @idDepartemen = idDepartemen FROM Departemen WHERE nmDepartemen=@nmDepartemen

IF @StatementType = 'Update'
BEGIN
UPDATE PC
SET idFactory=@idFactory,
idDepartemen=@idDepartemen,
nmKomputer=@nmKomputer,
nmUser=@nmUser,
Email=@Email,
Jenis=@Jenis,
Procesor=@Procesor,
Frek=@Frek,
Memory=@Memory,
Hdd=@Hdd,
Monitor=@Monitor,
OS=@OS,
Software=@Software,
Statuss=@Statuss
WHERE idPC=CONVERT(varchar(36),@idPC)


--SELECT * FROM PC
END



sabinWeb MCP
Go to Top of Page

ddtopgun
Starting Member

26 Posts

Posted - 2014-06-04 : 08:55:36
Hi Stepson i already try the first and the 2nd code but the output still same 0 rows (s) affected..the data still can't update...

fyi,
idPC,idFactory,idDepartemen is uniqueidentifier type

Go to Top of Page

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-06-04 : 09:08:58
Trigger ?

can you post some sample data?



sabinWeb MCP
Go to Top of Page

ddtopgun
Starting Member

26 Posts

Posted - 2014-06-04 : 09:24:29
not trigger but sp

below code for exec the sp


exec sp_isudpc 'mo','it','dsitest','testing','tes','pc','pc p4','3','1','80','lcd','xp','2003','','Update'

Go to Top of Page

ddtopgun
Starting Member

26 Posts

Posted - 2014-06-04 : 10:04:00
case closed thanks...i already found my problem so now i can update the data..thank's to stepson for yr help
Go to Top of Page

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-06-05 : 00:58:58
Welcome!


sabinWeb MCP
Go to Top of Page
   

- Advertisement -