Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

User Defined Data type Problem
Hi 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


Report this thread to moderator Post Follow-up to this message
Old Post
FA
12-29-05 06:23 PM


Re: User Defined Data type Problem
May 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 ***

Report this thread to moderator Post Follow-up to this message
Old Post
Amish Shah
12-30-05 12:23 PM


Re: User Defined Data type Problem
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


Report this thread to moderator Post Follow-up to this message
Old Post
Moe
12-31-05 01:23 AM


Re: User Defined Data type Problem
User 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
>


Report this thread to moderator Post Follow-up to this message
Old Post
Tibor Karaszi
12-31-05 08:23 AM


Re: User Defined Data type Problem
It 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


Report this thread to moderator Post Follow-up to this message
Old Post
amish
12-31-05 12:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 04:20 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006