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 |
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-03-25 : 06:36:34
|
| Hi..i am trying to use case statement in my script i am getting syntax error.could you able to solve this issue.SELECT @SQL =(CASE WHEN INSERT_DATE >= @TODAYTHEN '1'ELSE '0'END)GROUP BY @tablename'insert into INSERT_COUNT (TABLE_NAME, NO_OF_INSERTS) SELECT ''' + @TableName + '''as TABLE_NAME, COUNT(*) as INSERT_COUNT ' +'FROM [' + @TableName + '] where' + convert(varchar, @INSERT_DATE) +' >= '''+ convert(varchar, @TODAY) + ''' group by ' + @tablename + ''The syntax error messageMsg 102, Level 15, State 1, Line 40Incorrect syntax near 'insert into INSERT_COUNT (TABLE_NAME, NO_OF_INSERTS) SELECT ''.thanxSatya |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-25 : 06:44:07
|
What you have posted isn't understandable.What do you want to do?Where should the case be included and why? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-25 : 06:44:11
|
| SELECT @SQL =CASE WHEN INSERT_DATE >= @TODAYTHEN '1'ELSE '0'END from @tablename |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-03-25 : 06:58:33
|
| fred..in my table i got all the nullS for the columns NO_OF_INSERTS and NO_OF_UPDATES whis is INSERT_DATE and UPDATE_DATE.What i am looking is, for all the tables in the TABLE_NAME column i need the count for each perticular table for INSERT_DATE >= SYSDATE()same for UPDATE_DATE as welli want to use case statement inthe script Where INSERT_COUNT and UPDATE_COUNT.i want to use case to get the count for insert_date and update_date. present my table looks likeRDB_PAS_PCATEGORY 6 NULL NULLRDB_PAS_NAT_ADM 55 NULL NULLRDB_PAS_APP_ELECTIVES 10019 NULL NULLRDB_PAS_NAT_ADM_REASON 55 NULL NULLThere is an INSERT_DATE and UPDATE_DATE columns in all RDB tables.this script is all about to get all the counts i.e table_name,row_count,no_of_inserts n no_of_upadtes in the new table.thanxSatya |
 |
|
|
|
|
|
|
|