×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Cross Join in an Insert Into

Cross Join in an Insert Into

Cross Join in an Insert Into

(OP)
Please see the query below. When I run the Insert Into... by itself, it runs, but when I run the entire query it fails with - Column name or number of supplied values does not match table definition.
I'm trying to automate this query is why I have the T1 and T2. Thanks in advance for all of your help!
; WITH T1 AS (
SELECT *
FROM PPNO_DB.dbo.REF_CALENDAR
WHERE
YEAR = YEAR(GETDATE())
AND
MTH = MONTH(GETDATE())
AND DATE_DAY = 'Monday'
AND
RIGHT(DATE,2) BETWEEN '06' AND '13'
)

, T2 AS (
SELECT *,
CASE
WHEN CONVERT(DATE, GETDATE()) = T1.DATE
THEN 1
ELSE 0
END AS CHECK_DATE
FROM T1
)

--003_PNV_MMA_Networkdata Refresh Process
INSERT INTO AdHocData.MDCOutEd.PNV_MMA_NetworkData_Hist
SELECT *
FROM AdHocData.MDCOutEd.PNV_MMA_NetworkData_Curr
CROSS JOIN T2
WHERE T2.CHECK_DATE != '0'

RE: Cross Join in an Insert Into

My guess is that your query is returning one or more columns that are either in a different location or don't exist in your target table. Rather hard to tell without seeing the table structures.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close