We help IT Professionals succeed at work.

SSIS 2005, Adding a comment line

Hi and thanks,

I would like to add a comment line in:
Execute SQL Task - SQLStatement

I have tryed:

-- add comment line
* add comment line
// add comment line
/* add comment line
*/ add comment line

Still I get errors

Please help and thanks
Comment
Watch Question

Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
-- This is a comment line

/*
This is a comment block
*/

So ... copy-paste your 'SQL Task - SQL Statement' into this quetsion.

Author

Commented:
jimhorn,


I had this:

-- This table gets deleted
Drop Table [TblError]
GO


And I received an error on:
-- This table gets deleted

Should I have it like:
/*
This table gets deleted
*/
Drop Table [TblError]
GO

Thanks

Author

Commented:
jimhorn,


I just tryed and received Error?

Thanks
Simone BBI & Reporting Analyst

Commented:
Any query that runs successfully in Management Studio should run successfully in an Execute SQL task. Try running your query in Mgmt Studio first, including all of your comments, and see if you get any errors. Please post any errors you receive.
Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
The below should work, I removed the square brackets. So spell out the error that you're getting.

-- This table gets deleted
Drop Table TblError
GO

Open in new window


Also, if the table does not exist, dropping it will throw an error, so try this:

-- This table gets deleted
IF OBJECT_ID('TblError') IS NOT NULL
   Drop Table TblError
GO

Open in new window

Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
Also, the word GO executes all tasks up to that point, so if this is in the middle of a longer script any variables that were previously declared go away.

So ... You may want to split up the DDL tasks like dropping tables into one SQL task, and the DML tasks that manipulates data in those tasks in the next SQL task.

Author

Commented:
jimhorn,

Are you saying if I declare a variable see attachment:
Execute SQL Task

and have a multable sql statements that need the varable.  I can not do it like:

INSERT INTO tblError ( lngCount, strError )
SELECT Count(tblAuto.acct_num) AS CountOfacct_num, "Grant DV based on tag desc" AS Expr1
FROM tblAuto
WHERE (((tblAuto.tag_desc) Like "*Disabled vet*") AND ((tblAuto.bill_end)>[TaxYear]))
GROUP BY tblAuto.decal_typ_ndx
HAVING (((Count(tblAuto.acct_num))>0) AND ((tblAuto.decal_typ_ndx)=1));
GO
UPDATE tblAuto INNER JOIN dbo_auto ON (tblAuto.item = dbo_auto.item) AND (tblAuto.acct_num = dbo_auto.acct_num) SET tblAuto.decal_typ_ndx = 5, dbo_auto.decal_typ_ndx = 5
WHERE (((tblAuto.decal_typ_ndx)=1) AND ((tblAuto.tag_desc) Like "*Disabled vet*") AND ((tblAuto.bill_end)>[TaxYear]));
GO

And have it check for TaxYear?
Wow that would not be nice......


Thanks
Varables.docx

Author

Commented:
Hi,


I tryed the:

-- Comment line

and received an error on that line
Error: 0xC002F210 - Task Name, Execute SQL Task: Executing the query "-- Comment line

Need help what am I doing wrong?
Thanks
SQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015
Commented:
Perhaps Script Tasks cannot process comments, remove them and try again.

You can always write an annotation outside of the task.

Also, it might not be able to handle multiple GO statements.

>And have it check for TaxYear?
You'll have to use ? to signify a parameter, then in the Variables section add a variable to feed that parameter.

Author

Commented:
Thanks
Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
Thanks for the grade.  Good luck with your project.  -Jim

Explore More ContentExplore courses, solutions, and other research materials related to this topic.