You are here: Re: Newbie with SQL Server Trigger « MsSQL Server « IT news, forums, messages
Re: Newbie with SQL Server Trigger

Posted by ricardo.sobral.santos on 02/21/07 22:05

Yes that is something I was needing.
I need to convert an Hex type to Varchar and use that as a id. I would
like to use an integer but the cast would not work.

I think I might have the answer.

ALTER TRIGGER myTrigger_INSERT ON aspnet_Membership FOR INSERT AS

--this is an INSERT FROM SELECT
INSERT INTO WikedCompetitions.dbo.testTable
SELECT
CAST(userId AS VARCHAR(16)), --pay attention to the column sizes
because of the uniqueidentifier type
(SELECT UserName FROM aspnet_Users WHERE aspnet_Users.UserId =
inserted.UserId),
Email,
Password
FROM inserted

So this casts the userID(Hex) from aspnet_Users table to Users table
which has a field called UserID as a Varchar(16).

the only big problem is the ammount of space that this is going to use
because it is a varchar.

Tks for the help.

Ricardo

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация