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
 Transact-SQL (2008)
 need a help about strings's error

Author  Topic 

CoolMoon2011
Starting Member

31 Posts

Posted - 2012-01-06 : 16:42:28
when I run this query, I got this error below.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '='. Anyone would like to help me out and fix it. Thanks ahead here.

my query is below.

declare
@execstring1 varchar(1000),
@execstring2 varchar(1000)


select @execstring1= 'Runtype =EV'



select @execstring2 ='groupcode = mosesplan + ''_'' + premtype + ''_'' + biooptions + ''_'' +
case when bpinbaseplan < 4 then ''2'' when bpinbaseplan < 6 then ''4'' else ''L'' end
+ ''_'' + nh_coverage + ''_'' + case when [iss-year] < 2007 then ''O'' else ''N'' end + ''_''
+ ''cast(company as varchar(2))'''


exec (@execstring1 + @execstring2)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-01-06 : 17:04:22
print @execstring1
print @execstring2
print @execstring1 + @execstring2

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-01-06 : 17:10:36
Here is the string that you generated:[CODE]Runtype =EVgroupcode = mosesplan + '_' + premtype + '_' + biooptions + '_' +
case when bpinbaseplan < 4 then '2' when bpinbaseplan < 6 then '4' else 'L' end
+ '_' + nh_coverage + '_' + case when [iss-year] < 2007 then 'O' else 'N' end + '_'
+ 'cast(company as varchar(2))'[/CODE]What are you attempting to accomplish with this string?

=================================================
Men shout to avoid listening to one another. -Miguel de Unamuno
Go to Top of Page
   

- Advertisement -