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 2005 Forums
 Transact-SQL (2005)
 insert in table for special group

Author  Topic 

veronika.np
Starting Member

29 Posts

Posted - 2011-06-13 : 11:11:37
hi freinds
i have problem.
i have 3 tables student,studentcategory,award.
i want to find students that have special category and insert their id in award table.



CREATE TABLE [dbo].[student](
[id] [int] NOT NULL,
[name] [nchar](10) NOT NULL,
[studentcategoryid] [int] NOT NULL
) ON [PRIMARY]


insert into student values
(1,'st1',1)
(2,'st2',1)
(3,'st3',1)


student category table

CREATE TABLE [dbo].[studentcategory](
[id] [int] NOT NULL,
[name] [nchar](10) NOT NULL
) ON [PRIMARY]

insert into studentcategory values
(1,'art')
(2,'accounting')




award table


CREATE TABLE [dbo].[award](
[id] [int] NOT NULL,
[studentid] [nchar](10) NULL
) ON [PRIMARY]





i want insert in award table for students that their studentcategoryid are "1"



please help me.
thanks

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-13 : 12:32:00
maybe
insert award (studentid)
select id
from student
where studentcategoryid = 1

How do you allocate the award.id?


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

veronika.np
Starting Member

29 Posts

Posted - 2011-06-13 : 12:50:50
quote:
Originally posted by nigelrivett

maybe
insert award (studentid)
select id
from student
where studentcategoryid = 1

How do you allocate the award.id?


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.


thanks,but @studentcategoryid is xml.i want to
where studentcategoryid = @studentcategoryid
how can i do it?
please help me.
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-13 : 13:13:37
>> @studentcategoryid is xml
Not in your structure.

insert award (studentid)
select id
from student
where studentcategoryid = @studentcategoryid


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

veronika.np
Starting Member

29 Posts

Posted - 2011-06-13 : 14:14:19
quote:
Originally posted by nigelrivett

>> @studentcategoryid is xml
Not in your structure.

insert award (studentid)
select id
from student
where studentcategoryid = @studentcategoryid


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.



i send data from .net to sql with xml format.and with xml prepare document i open it.but i don`t know how access to id in xml?
Go to Top of Page
   

- Advertisement -