Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

T-SQL 1

Status
Not open for further replies.

abdhab

MIS
Dec 10, 2006
51
CA
hi
i am trying to use a t-sql command in access, i know nothing about jet sql
my command is:

declare @counter int
set @counter = 1
while @counter <= (select count(*) from dbo_employees)
begin
insert into dbo_fup(eid, fdate) values(@counter, '12/10/06')
set @counter = @counter + 1
end

but somehow it is not working.. will it work if i convert it to jet sql? if yes, can some1 convert it please?
 
You cab't do this in Jet SQL - unfortunately it's nowhere near as powerful/flexible as other implementations of the SQL standard.

Somebody here may be able to show how this can be done in Jet SQL (my SQL isn't great), but personally I'd do it in VBA.

Ed Metcalfe.

Please do not feed the trolls.....
 
declare your dbo_fup table with eid defined as an autonumber

then run this query:
Code:
insert 
  into dbo_fup 
     ( fdate )
select #2006-12-10#
  from dbo_employees
simple, yes ;-)

r937.com | rudy.ca
 
thank you for your quick reply guys.
r937, your code works fine if dbo_fup is empty, in addition i need eid set to be equal from 1 to X each time i use the insert code, so i cannot leave eid as autonumber
 
ok guys, i just did a few modification in the code:
Code:
insert 
  into dbo_fup 
     ( fdate, eid )
select #2006-12-10#, eid
  from dbo_employees

it works fine now
thank you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top