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 2008 Forums
 Other SQL Server 2008 Topics
 Create Table Query Help

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2009-02-05 : 21:47:52
I am trying to create a new table. This is what I have:
create table MCR_Reimb as

================================
(select ffs_pmts.[provider name], ffs_pmts.[PRCDR CODE] as mcd_prcdr, ffs_pmts.[Paid Service Units] as units,
ffs_pmts.[payment amount] as mcd_p,mcr_fee_sched.[Proc], MCR_Fee_Sched.[Payment] as mcr_fee,(ffs_pmts.[Paid Service Units]*mcr_fee_sched.[Payment]) as mcr_p, (ffs_pmts.[Paid Service Units]*mcr_fee_sched.[Payment])- (ffs_pmts.[payment amount])as variance

from FFS_Pmts LEFT OUTER JOIN
mcr_fee_sched on ffs_pmts.[PRCDR CODE] = mcr_fee_sched.[Proc]

where MCR_Fee_Sched.[Payment] is not null)
==========================

and this is the error I keep getting:

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'as'.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-05 : 22:21:38
[code]SELECT FFS_PMTS.[PROVIDER NAME],
FFS_PMTS.[PRCDR CODE] AS MCD_PRCDR,
FFS_PMTS.[PAID SERVICE UNITS] AS UNITS,
FFS_PMTS.[PAYMENT AMOUNT] AS MCD_P,
MCR_FEE_SCHED.[PROC],
MCR_FEE_SCHED.[PAYMENT] AS MCR_FEE,
(FFS_PMTS.[PAID SERVICE UNITS] * MCR_FEE_SCHED.[PAYMENT]) AS MCR_P,
(FFS_PMTS.[PAID SERVICE UNITS] * MCR_FEE_SCHED.[PAYMENT]) - (FFS_PMTS.[PAYMENT AMOUNT]) AS VARIANCE

INTO MCR_Reimb
FROM FFS_PMTS
LEFT OUTER JOIN MCR_FEE_SCHED
ON FFS_PMTS.[PRCDR CODE] = MCR_FEE_SCHED.[PROC]

WHERE MCR_FEE_SCHED.[PAYMENT] IS NOT NULL[/code]
Go to Top of Page

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2009-02-06 : 08:22:24
Thank you. This worked perfectly.
quote:
Originally posted by sodeep

SELECT FFS_PMTS.[PROVIDER NAME],
FFS_PMTS.[PRCDR CODE] AS MCD_PRCDR,
FFS_PMTS.[PAID SERVICE UNITS] AS UNITS,
FFS_PMTS.[PAYMENT AMOUNT] AS MCD_P,
MCR_FEE_SCHED.[PROC],
MCR_FEE_SCHED.[PAYMENT] AS MCR_FEE,
(FFS_PMTS.[PAID SERVICE UNITS] * MCR_FEE_SCHED.[PAYMENT]) AS MCR_P,
(FFS_PMTS.[PAID SERVICE UNITS] * MCR_FEE_SCHED.[PAYMENT]) - (FFS_PMTS.[PAYMENT AMOUNT]) AS VARIANCE

INTO MCR_Reimb
FROM FFS_PMTS
LEFT OUTER JOIN MCR_FEE_SCHED
ON FFS_PMTS.[PRCDR CODE] = MCR_FEE_SCHED.[PROC]

WHERE MCR_FEE_SCHED.[PAYMENT] IS NOT NULL


Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-06 : 10:50:40
Good
Go to Top of Page
   

- Advertisement -