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 2000 Forums
 Transact-SQL (2000)
 INSERT Question

Author  Topic 

evanburen
Posting Yak Master

167 Posts

Posted - 2006-12-21 : 21:35:35
I want to insert a new record into a table TCompProfileCustom where the userID matches the table TSubscribers. I'm not sure how to do this. Thanks

INSERT INTO TCompProfileCustom
(UserID, ProfileName, DateCreated, divDefault, divOrder)
Vales(?, 'ProfileName, '12/21/2006', 0, 'Div1, Div2')

evanburen
Posting Yak Master

167 Posts

Posted - 2006-12-21 : 21:45:13
I didn't phrase this question very well.

I want to insert a new record into TCompProfileCustom where the AccountNo in Tsubscribers is '00245'. The userID value in the insert statement comes from the TSubscribers table. Thanks.

insert into TCompProfileCustom
(UserID, ProfileName, DateCreated, divDefault, divOrder)
VALUES (select tsubscribers.userid
from tsubscribers
where tsubscribers.AccountNo='00245', 'Test', '12/22/2006', 0, 'Div1')
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-21 : 22:36:20
[code]insert into TCompProfileCustom (UserID, ProfileName, DateCreated, divDefault, divOrder)
select userid, 'Test', '12/22/2006', 0, 'Div1'
from tsubscribers
where AccountNo='00245'[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-22 : 00:35:35
<<
'12/22/2006'
>>

If the server date format is DMY, that will give you error
Always use Universal Format

'20061222'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -