I am brand new to using SQL Server, although I have considerable experience of SQL programming with other (mainly Open Source) databases. I am converting an Access Application (with Access Front End against and Access Backend database) into an Access Front End with SQL Server (SQL Server 2008 R2 Express Edition). I have lots of this working, and am now trying to address certain places where I think I should do something special. A piece of the old version of the application imports a CSV file with some "prospects" into a a local table in the front and then (in VBA) proceeds to merge them into a "Prospect" table in the main database.I am trying to convert this into load the CSV into a temporary table and then call a stored procedure to do all the "Merge" processing. I am currently trying to make the stored procedure, but am failing to get very far. I'll try and split all the questions into small chunks over several posts, but here are my initial ones.- I am getting loads of error messages likequote: Msg 1038, Level 15, State 4, Procedure LeadsImport, Line 29An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.
How do I count Line 29 from - If I count from the start of CREATE PROCEDURE, it comes out at the first line of this, but then later there are messages refering to line 30. INSERT INTO [dbo].[Prospect] ( [creationDate], [title], [firstname], [lastname], [hseNoStName], [address1], [town], [county], [postcode], [email], [allow_email], [allow_tel], [callBackTime], [source], [gender], [notes], [consPeriod], [consWhen], [procedure], [infoPackSent], [infoPackRequested], [UcFname], [UcLname], [UcPcode], [leadID], [nextAction], [actionDue] ) SELECT p.[Date_added_dt], [dbo].[InitCap](p.[Title]), [dbo].[InitCap](p.[Firstname]), [dbo].[InitCap](p.[Lastname]), [dbo].[InitCap](mid([dbo].[TRIM]([dbo].[TRIM](p.[House]) &" " & [dbo].[TRIM](p.[Address1])))1,60)), [dbo].[InitCap](mid([dbo].[TRIM]([dbo].[TRIM](p.[Address2]) & " " & [dbo].[TRIM](p.[Street])),1,60)), [dbo].[InitCap](p.[Town_City]), [dbo].[InitCap](p.[County]), UPPER(p.[PostCode]), p.[Email], p.[Allow_email], p.[Allow_tel], p.[Callback_range], ISNULL(p.[Source],"Web Site"), CASE p.[Sex] WHEN "Male" THEN "M" ELSE NULL END, p.[Further_info], p.[Cons_period], p.[When], p.[Procedure], p.[Info_pack] = "Email", p.[Info_pack] = "Post", p.[UcFname], p.[UcLname], p.[UcPcode], p.[leadID], CASE WHEN p.[consultation]="yes" THEN 2 WHEN p.[Info_pack]="Post" THEN 4 ELSE 1 END , p.[date_added_dt], FROM ( SELECT p.* FROM [dbo].[#WebsiteLeads] p INNER JOIN ( SELECT MAX([leadID]) as latestLeadID, [UcFname], [UcLname], [UcPcode] FROM [dbo].[#WesSiteLeads] GROUP BY [UcFname], [UcLname],[UcPcode] ) W ON p.[leadID] = W.[latestLeadID] ) AS p LEFT JOIN [dbo].[Prospect] ON p.[UcFname] = [dbo].[Prospect].[UcFname] AND p.[UcLname] = [dbo].[Prospect].[UcLname] AND (Coalesce(p.[UcPcode],"") = "" OR p.[UcPcode] = [dbo].[Prospect].[UcPcode] ) WHERE [dbo].[Prospect].[UcFname] IS NULL AND [dbo].[Prospect].[UcLname] IS NULL; What does the error message mean anyway. I can't see what is wrong with this |