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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-04-07 : 08:01:56
|
| thomas writes "hi,i'm trying to get an if..goto clause into the statement below.thought that 'if' +@comp + ' like 'c1' goto lab1 ';would work but i'll always get " error near c1 "can you help??thanx in advance ' drop table ' + @tab2 + ' drop table ' + @tab4 + ' select comp, b_date, t_date sum(price) price, sum(pax) pax, dupchk into ' + @tab2 + ' from ' + @tab1 + ' where b_date between ''' + @bdat1 + ''' and ''' + @bdat2 + ''' and t_date between ''' + @tdat1 + ''' and ''' + @tdat2 + ''' and company = ''' + @comp + ''' and dupchk not like ''' + @dupchk + ''' group by comp, b_date, t_date dupchk ';" |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-07 : 09:00:49
|
| why are your table names variable in this procedure? What is your database design? You should not have 1 table per customer or something similiar to that. Your table names should always be constants in any given stored procedure, other than administrative DBA-type scripts.- Jeff |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2005-04-07 : 09:02:59
|
| I suspect you've cut out something important from your code snippet....as the ONLY 2 references to C1 are in your narrative....and NOT IN the code sample.Also....you need to learn more about the CODE CONSTRUCTS available in SQL. It's not a PROCEDURAL language like VB, ASP, etc.....Concepts used therein don't necessarily transfer to SQL.Reading BOL and other sources (tutorial exercises, etc) should get you moving more. |
 |
|
|
|
|
|