December 1, 2013 at 10:21 pm
There is a syntax problem with the third column b.id and the last ')'.
But I cant figure out why.
Can someone help me? I need to get this done tonight:(
[Code="sql"]
INSERT into user_def_fields
('VMPRTMNT','UDF-0000022',b.ID,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,b.[Create date])
SELECT
b.ID,
b.[Create date]
FROM wmvw_PartCreateDate as b
[/code]
December 1, 2013 at 10:26 pm
What goes inside the brackets in your INSERT () are the column names in the table you're inserting into. You have a bad mix of the INSERT ... VALUES form and the INSERT ... SELECT form of insert. I suggest you open up Books Online and have a look at the two forms.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 1, 2013 at 11:12 pm
Gail,
Thank you.
Still downloading BOL to my new laptop. Another 6 minutes to go.
But your comments really helped I think.
Would this work?
INSERT into user_def_fields
(
program_id,
id,
Document_id,
Line_no,
Del_Line_no,
Label,
Data_Type,
Display_Format,
Tab_or_Table,
Tab_ID,
Table_ID,
Sequence_No,
UDF_Required,
String_Val,
Number_Val,
Bool_Val,
date_val
)
SELECT
'VMPRTMNT',
'UDF-0000022',
b.ID,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
b.[Create date]
FROM wmvw_PartCreateDate as b
December 1, 2013 at 11:29 pm
Yes, It will work
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
December 1, 2013 at 11:51 pm
TC-416047 (12/1/2013)
Would this work?
Wouldn't it be faster to run it and see if it works?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 2, 2013 at 8:17 am
yes...
I did...
It worked...
Thank you for helping.
-Todd
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply