SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 15th, 2004, 12:49 PM
desireemm desireemm is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 31 desireemm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 38 m 35 sec
Reputation Power: 5
Unhappy stored Procedure

Does anyone see anything wrong with this statement, I keep getting an Incorrect Syntax message must declare the variable

Code:
CREATE PROCEDURE [insert_Corovan_Table_1]
@pdBegin  DATETIME =  TerminationDate (BETWEEN CONVERT(DATETIME, '2003-01-01 00:00:00', 102) AND CONVERT(DATETIME, '2003-12-31 00:00:00', 102))
@pdEnd	DATETIME=   NULL
AS
IF @pdBegin IS NULL
   SET @pdBegin = DateAdd(year, -2, GetDate())
IF @pdEnd IS NULL
   SET @pdEnd = DateAdd(year, 1,@pdBegin)
AS INSERT INTO [GamingCommissiondb].[dbo].[Corovan_Table] 
  ( [TM #],
  [FirstName],
  [LastName],
  [SS #],
  [TerminationDate],
  [Voluntary or Involuntary],
  [Notes]) 
SELECT   ([TM#],  
  [FirstName], 
  [LastName],  
  [SS #],  
  [TerminationDate],  
  [Voluntary_or_Involuntary],
  [Notes],)
FROM TERMINATION 
GO

Reply With Quote
  #2  
Old September 15th, 2004, 12:52 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
Which variable?
Is TerminationDate a UDF?

Reply With Quote
  #3  
Old September 15th, 2004, 12:54 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
You have 2 "AS" statements in your code.
Code:
CREATE PROCEDURE [insert_Corovan_Table_1]
@pdBegin  DATETIME =  TerminationDate (BETWEEN CONVERT(DATETIME, '2003-01-01 00:00:00', 102) AND CONVERT(DATETIME, '2003-12-31 00:00:00', 102))
@pdEnd	DATETIME=   NULL
AS
IF @pdBegin IS NULL
   SET @pdBegin = DateAdd(year, -2, GetDate())
IF @pdEnd IS NULL
   SET @pdEnd = DateAdd(year, 1,@pdBegin)
AS INSERT INTO [GamingCommissiondb].[dbo].[Corovan_Table] 
  ( [TM #],
  [FirstName],
  [LastName],
  [SS #],
  [TerminationDate],
  [Voluntary or Involuntary],
  [Notes]) 
SELECT   ([TM#],  
  [FirstName], 
  [LastName],  
  [SS #],  
  [TerminationDate],  
  [Voluntary_or_Involuntary],
  [Notes],)
FROM TERMINATION 
GO

Reply With Quote
  #4  
Old September 15th, 2004, 12:56 PM
desireemm desireemm is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 31 desireemm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 38 m 35 sec
Reputation Power: 5
reply

No it is not a user defined function

Reply With Quote
  #5  
Old September 15th, 2004, 12:58 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
Try this
Code:
CREATE PROCEDURE [insert_Corovan_Table_1]
@pdBegin  DATETIME =  TerminationDate (BETWEEN CONVERT(DATETIME, '2003-01-01 00:00:00', 102) AND CONVERT(DATETIME, '2003-12-31 00:00:00', 102))
@pdEnd	DATETIME=   NULL
AS
IF @pdBegin IS NULL
   BEGIN
      SET @pdBegin = DateAdd(year, -2, GetDate())
   END

IF @pdEnd IS NULL
   BEGIN
      SET @pdEnd = DateAdd(year, 1,@pdBegin)
   END 
 
INSERT INTO [GamingCommissiondb].[dbo].[Corovan_Table] 
  ([TM #],
  [FirstName],
  [LastName],
  [SS #],
  [TerminationDate],
  [Voluntary or Involuntary],
  [Notes]) 
SELECT   ([TM#],  
  [FirstName], 
  [LastName],  
  [SS #],  
  [TerminationDate],  
  [Voluntary_or_Involuntary],
  [Notes],)
FROM TERMINATION 
GO

Also, I don't see a WHERE Clause in your SELECT statement.
Are you meaning to pull all the records in?

Reply With Quote
  #6  
Old September 15th, 2004, 12:58 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
Then what is it?

Reply With Quote
  #7  
Old September 15th, 2004, 01:33 PM
desireemm desireemm is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 31 desireemm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 38 m 35 sec
Reputation Power: 5
Field

Termination Date is just a field that has the termination Date, the data type is DATETIME

Reply With Quote
  #8  
Old September 15th, 2004, 01:35 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
okay, now I am confused.

What exactly is this, then?
Code:
@pdBegin  DATETIME =  TerminationDate (BETWEEN CONVERT(DATETIME, '2003-01-01 00:00:00', 102) AND CONVERT(DATETIME, '2003-12-31 00:00:00', 102))

Reply With Quote
  #9  
Old September 15th, 2004, 01:42 PM
desireemm desireemm is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 31 desireemm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 38 m 35 sec
Reputation Power: 5
Ok

What I am trying to do is Move Data from one table to another automatically once year. I want the stored procedure to execute once a year. I want the 2003 Terms data to go to the Corovan table at the beginning of 2005. Thats what I am trying to do.

Reply With Quote
  #10  
Old September 15th, 2004, 02:00 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
I understand that, what I don't understand is the code of yours I pasted above?

It looks to me like you are setting the value of @pdBegin to the returned results of a UDF.

Reply With Quote
  #11  
Old September 15th, 2004, 02:55 PM
desireemm desireemm is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 31 desireemm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 38 m 35 sec
Reputation Power: 5
I see

Yes actually thats what it looks like to me also. I inhertied this database and I'm analyzing alot of the procedures and structure this is the one I am having the most problems with

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > stored Procedure


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |