Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dymanic Query

Status
Not open for further replies.

jnavarro

Programmer
Dec 1, 2003
89
US
Can any one tell what is wrong with this query. I am trying to update information based on the parameters,I get an message 0 rows effected. However, if I do it manually it works.

-SET @SQL=' UPDATE tblAIAttachments SET Div=' + @Div + 'SET Account =' + @Account + 'WHERE Div=' + @Org_Div + 'AND Account=' + @Org_Account + ' AND Location in(' + @Location + ') ' -- AND UpdateDate >= convert(char(11),@MediaDate,101)
EXECUTE(@SQL)
 
I did that but I am receiving an error Error converting data type varchar to bigint.

I have provide my declare also.
DECLARE @Div char(2),@Account bigint, @CorrespondType char(3), @MediaDate datetime, @Org_Div char(2), @Org_Account bigint, @Location varchar(500)
DECLARE @SQL varchar(700)


Any ideas what is causing this?

 
I have also try this but I get 0 records affected

UPDATE tblAIAttachments
SET Div= @Div, Account = @Account
WHERE Location IN(''+ @Location + '') AND Div= @Org_Div AND Account= @Org_Account

@Location variable is set ='\\GLAPPS02OHCSAPPS\AI\FL8192A2.PDF',
'\\GLAPPS02\OHCSAPPS\AI\FL8192A2.PDF',
'\\GLAPPS02\OHCSAPPS\AI\FL8192A2.PDF',
'\\GLAPPS02\OHCSAPPS\AI\FL8192A2.PD'
 
the error message is pretty clear

why don't you echo out your sql string instead of executing it, so that you can see where the quotes are superfluous or missing

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top