Drop Table
Support Forum for database administrators and web based access to important newsgroups related to databasesHi Friends, I have a small problem hoping that you experts can resolve it. I need to make a user defined data type for a field. My field name is FINDG_NO(PK) and its datatype needs to be (Five fillers alphabatic then today's date, and then two fillers at the end alphanumeric) Here is the example: ABCDE12/29/05N2. The date should come automatic each time the new record is being entered. the fillers needs to be filled by user. Can someone help me pleaseeeeeeeee Moe
Post Follow-up to this messageMay this one help you
create table test
(val varchar(100) not null,
data varchar(100))
alter table test
add constraint pk_val primary key (val)
create trigger testtrig on test
instead of insert
as
begin
declare @id int
select @id = len(val) from inserted
if @id <> 7
rollback
else
insert into test select left(val,5) + convert(char(10), getdate(),103) +
right(val,2),data
from inserted
end
insert into test values('ABCDEN2','th
is is a sample')
Regards
Amish
*** Sent via Developersdex http://www.droptable.com ***
Post Follow-up to this messageThanks Amish, i tried this and it didnt work. This is the first time i am working with sql server so please bear with me. Is there any way i can do something in the User Defined Data Type. I was going through Pub Database in sql and it has some UserDefinedDataTypes . Can you tell me something like this or the code of how to do it. Or i can simply go into table's properity and in Constraint i can write some code so that the FINDG_NO field can only take that type of data in the same format as mentioned in my first message. Please help me freind. Thanks Moe
Post Follow-up to this messageUser defined datatype, default, rules or the more modern concepts "constrain ts" will not help you here as all they does is to constraint what information you are allowed. The y do not change things for you. -- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www. solidqualitylearning .com/ Blog: http:// solidqualitylearning .com/blogs/tibor/ "Moe" <October.April@gmail.com> wrote in message news:1135980841.024236.309190@o13g2000cwo.googlegroups.com... > Thanks Amish, i tried this and it didnt work. This is the first time i > am working with sql server so please bear with me. Is there any way i > can do something in the User Defined Data Type. I was going through Pub > Database in sql and it has some UserDefinedDataTypes . Can you tell me > something like this or the code of how to do it. Or i can simply go > into table's properity and in Constraint i can write some code so that > the FINDG_NO field can only take that type of data in the same format > as mentioned in my first message. > > Please help me freind. > > Thanks > Moe >
Post Follow-up to this messageIt should work what problem you face in the script or can you tell me what data you get in the table after running the script. Regards Amish
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread