Showing posts with label record. Show all posts
Showing posts with label record. Show all posts

Thursday, March 29, 2012

create table with TRIGGER

I need an Insert trigger to generate new tables when i insert a new record..
new tables will be "MasterSub_[ID]" where ID is the id of new inserted
parent record..
I also want a delete triger to remove child table if it has no data in it..
Any help plz'This is a very bad design and will likely perform poorly. Why do you need
to create tables every time you insert rows?
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"Islamegy" <NULL_Islamegy_NULL@.yahoo.com> wrote in message
news:uFTjXyR7FHA.1188@.TK2MSFTNGP12.phx.gbl...
>I need an Insert trigger to generate new tables when i insert a new
>record..
> new tables will be "MasterSub_[ID]" where ID is the id of new inserted
> parent record..
> I also want a delete triger to remove child table if it has no data in
> it..
> Any help plz'
>
>

Monday, March 19, 2012

Create record each day from time frame

I have a table that has cost records for a specific item for a specific star
t
date.
Start, cost, item, PromoCode, end date
01/02/2006, 2.45, 1234, R,
01/05/2006, 2.00, 1234, P, 01/08/2006
01/10/2006, 2.55, 1234, R,
If a record has a start date then that new cost begains. And if it doesn't
have an end date it will go indefinitely. Also when a promo (P) ends then
the cost goes back to the Regular (R) cost record.
So the cost records that I would create from the above records is
01/02/2006, 2.45, 1234, R
01/03/2006, 2.45, 1234, R
01/04/2006, 2.45, 1234, R
01/05/2006, 2.00, 1234, P
01/06/2006, 2.00, 1234, P
01/07/2006, 2.00, 1234, P
01/08/2006, 2.45, 1234, R
01/09/2006, 2.45, 1234, R
01/10/2006, 2.55, 1234, R
01/10/2006, 2.55, 1234, R
.....
Looking for any help with how to start a stored procedure or query to come
up with these records.
Thanks!Suggest joining to an auxiliary calendar table
See http://www.aspfaq.com/2519

Create procedure or trigger to auto generate string ID

Dear everyone,

I would like to create auto-generated "string" ID for any new record inserted in SQL Server 2000.

I have found some SQL Server 2000 book. But it does not cover how to create procedure or trigger to generate auto ID in the string format.

Could anyone know how to do that?? Thanks!!

From,

Royi dont think there is any "autogenerated string" you can only have a numeric column...you need to write your own script to get the next value if you decide to use strings ...

hth|||Do not use a string in your DB, rather cast it to a string when you need to use it.|||Thanks you for reply!!

I know there is no autogenerate string. But I need to use string value as primary key. When new record inserted, e.g. string 'A0001' should be generated automatically.

U said that script can help. Could u briefly tell me some steps by how to write??

Thanks for help!!!|||i got some code in my pc at work place...it will take a value and give you the next number/string..

xample:
if you pass 1 to it, it will return 2..
if you pass A1 it will return A2 and return Abcde45 if you pass Abcde44...
the only drawback is it wont work if you try to use a1a...as long as its string followed by number...it works...
i can share it here on monday if you are interested...

hth|||You can write a trigger on that table to fire on INSERT, and that will fill in the next number in your table.

Look up Triggers in Books Online|||Thanks you for reply!!

I could not find books for writing this procedure.

Could u share the code for what u said??

Thanks a lot!!!!!|||Look for SQL Server Books Online - it's a free reference. Do a Google search, I don't know the URL.

Wednesday, March 7, 2012

Create more than one detail

Hi K.Babu,

I have a problem how to make more than one detail in Crystal Report to one record, such as employer's information like this :

Code :0001
Name : AAAA
Address : BBBB

//Detail -1
Career :
1. ...
2. ...
3. ...

Hobby : music
Age : 27

//Detail -2
1. ...
2. ...
3. ...

Is it possible to print for the employee from Crystal Report 8.5
If yes, how can I do ?

Thank you.Your question is not very clear, but I'll do my best...

Have you tried using groups? I'm not sure how to set it up since I've never used it. Try doing a search for it.|||I have been tried using groups that is reference code_employee but I dont know how to create details for 2 tables. I mean that the first detail for first table and the second detail for second table. How to create that ?
Thank you...

Sunday, February 19, 2012

Create default

Hi All,
Can someone tell me how to create a default that put the current date into a record on insert and current date + 1 year into another record!?
Cheers Wimmouse getdate() in the field where date field is used in insert.|||Originally posted by nhariharan
use getdate() in the field where date field is used in insert.

I tried it, but i keeps the null value.|||use pubs
go
create table #abc
(
fname varchar(10),
joindate datetime default getdate(),
joinyear int default datepart(yyyy,getdate())
)
go
insert into #abc
(
fname
)
select
'Enigma'
go
select
*
from
#abc
go
drop table #abc
go|||Originally posted by Enigma

use pubs
go
create table #abc
(
fname varchar(10),
joindate datetime default getdate(),
joinyear int default datepart(yyyy,getdate())
)
go
insert into #abc
(
fname
)
select
'Enigma'
go
select
*
from
#abc
go
drop table #abc
go


Thanx the getdate() works.
I use 2 columns 1 named join date and 1 named enddate ,standard users get 1 year acces to the application so when a new user register the enddate must be automatically set 1 year after the joindate,
do you know how to manage that?

Thanx already.

Cheers Wim

I|||Originally posted by Wimmo
Thanx the getdate() works.
I use 2 columns 1 named join date and 1 named enddate ,standard users get 1 year acces to the application so when a new user register the enddate must be automatically set 1 year after the joindate,
do you know how to manage that?

Thanx already.

Cheers Wim

I
create table #abc
(
fname varchar(10),
joindate datetime default getdate(),
Enddate datetime default dateadd(yy,1,getdatE())
)|||Originally posted by harshal_in
create table #abc
(
fname varchar(10),
joindate datetime default getdate(),
Enddate datetime default dateadd(yy,1,getdatE())
)

I tried this but the result seems strange:

joindate 13-2-2004 11:48:45 enddate Feb 13 200|||Originally posted by Wimmo
I tried this but the result seems strange:

joindate 13-2-2004 11:48:45 enddate Feb 13 200

create table #abc
(
fname varchar(10),
joindate datetime default getdate(),
endate datetime default dateadd(yy,1,getdate())
)
go
insert into #abc
(
fname
)
select
'Enigma'
go
select
*
from
#abc
go
drop table #abc
go