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 from one tab to second tab.

Author  Topic 

marek
Starting Member

34 Posts

Posted - 2011-06-03 : 14:20:09
Hallo boys...

I have following problem.
I want insert data from TabCompany to TabSalesManager, but column "autor" and percentage are default ("autor"=marek and percentage=0)
ATTENTION! columns "autor", "percentage" not included TabCompany.

Tabcompany
NumCust....NumEmpl.....Branch.....date


TabSalesManager
NumCust....NumEmpl.....Branch.....date....autor....percentage


My syntax is not wokking:

insert into TabSalesManager (NumCust, NumEmpl, autor default 'marek', branch, percentage default 80.00, date)
select TabCompany (NumCust, NumEmpl, autor, branch, percentage, date)
from TabCompany
where /here is my condition that will do to select a date

I do not want add columns to Tabcompany,I am the reason why I have those 2 columns in TabSalesManager table... It must be so as I write.

Big thanks all for help.....
marek

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-06-03 : 14:26:37
insert into TabSalesManager (NumCust, NumEmpl, autor, branch, percentage , date)
select NumCust, NumEmpl, 'Marek', branch, 0, date
from TabCompany

is how it would be done in Microsoft SQL Server

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-03 : 14:27:25
I'm not sure where you came up with that syntax, but here's what it would be for T-SQL:

insert into TabSalesManager (NumCust, NumEmpl, autor, branch, percentage, date)
select NumCust, NumEmpl, 'marek', branch, 80.00, date)
from TabCompany
where ...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-03 : 14:28:23
By a whole minute!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-06-03 : 14:32:24
But the cool part is that we both pointed out that this is how it's done in SQL Server!

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-03 : 14:35:34
Yeah, I had a hunch that the OP is using a different dbms because the syntax is so weird.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

marek
Starting Member

34 Posts

Posted - 2011-06-03 : 14:43:23
yes SQL server 2008

ok..ok.....i will go try

ok.. big thanks
a total simple and I did not know



Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-03 : 14:55:19


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

marek
Starting Member

34 Posts

Posted - 2011-06-03 : 14:59:21
and photo? Why photo missing? my hobbies is oldtimers (veterans)

ok you are mistress in SQL server 2008.....

To my mind is SQL (studio,server2008) is best program for processing data.

Why I dont have with SQL studio 2008 else Report builder 3.0 ?
Report builder 3.0 is not automatically part (component) of SQL server 2008?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-03 : 15:00:31
What photo? I see nothing.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

marek
Starting Member

34 Posts

Posted - 2011-06-03 : 15:16:24
Go to Top of Page
   

- Advertisement -