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
 SQL Server Development (2000)
 Using cursors to populate a column

Author  Topic 

dprasad1
Starting Member

4 Posts

Posted - 2002-05-10 : 14:19:28
I am trying to populate a column with date/time info, I am doing this so I can use getdate() on the data for other computations (the format is mon/day/yr/hours/mins, i was told only data having mon/day/yr format can be used with getdate()). The code below says that dateyest is an invalid object name. Actually, any kind of insert I do reports the same error, no matter what column it is (securty on my account is all set, as well as for the stored proc.). I must be overlooking something very simple, right? thanks for the help!DECLARE @dateYest datetime
DECLARE Cur668 CURSOR
Keyset
FOR
SELECT cast(date1 as datetime) dt
FROM baclosetable
OPEN Cur668

fetch next from cur668 into @dateyest

WHILE @@FETCH_STATUS = 0
BEGIN
if @dateyest is not null
Insert dateyest VALUES (@dateYest)
fetch next from cur668 into @dateyest
END
CLOSE Cur668
DEALLOCATE Cur668






AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-05-10 : 15:08:34
The problem appears to be in your INSERT statement:

INSERT dateyest VALUES(@dateYest).

Is the first dateyest a valid name of a table in your database? The normal syntax is

INSERT YourTableName (fieldlist) VALUES (valuelist)

Go to Top of Page

aiken
Aged Yak Warrior

525 Posts

Posted - 2002-05-10 : 16:11:43
I'm also confused about the table you're trying to insert into. Are you trying to create a datetime column in baclosetable?

It also looks very likely that you don't need the cursor at all... can you post a more clear description of what tables you have and where you're trying to insert the datetime field?

Cheers
-b



Go to Top of Page
   

- Advertisement -