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 |
PanzerAttack
Yak Posting Veteran
71 Posts |
Posted - 2011-06-28 : 08:13:36
|
Please excuse this as I'm sure it's simple but I've never used sql before this week and I've done so much reading, I think I've gone blind.I'm simply trying to empty a table I'd loaded via SSISDELETE FROM 005 Actual vs AccrualsWHERE Import Date = 'Now()'But I get the errorMsg 102, Level 15, State 1, Line 1Incorrect syntax near '005'.Can someone please advise what I've missed out. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-28 : 08:15:37
|
That isn't looking like MS SQL Server (T-SQL).Are you sure that you are in the right forums?What is it? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
PanzerAttack
Yak Posting Veteran
71 Posts |
Posted - 2011-06-28 : 08:20:04
|
I'm using Sql 2005, I'm in the Microsoft SQL Server Management Studio and I clicked on New Query |
 |
|
PanzerAttack
Yak Posting Veteran
71 Posts |
Posted - 2011-06-28 : 08:23:00
|
This workedDELETE FROM G005_Actual_vs_AccrualsWHERE [Import Date] = 'Now()' |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-28 : 08:27:04
|
I don't the Now() function in SQL Server 2005.Are you sure it works?Also 'Now()' in single quotes is treated as a string and not as a function. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
PanzerAttack
Yak Posting Veteran
71 Posts |
Posted - 2011-06-28 : 08:40:23
|
The Now() is the text in the table the whole columns says Now(). My Attempt to populate the column with Date and Time when the data is imported. Thanks though. |
 |
|
theboyholty
Posting Yak Master
226 Posts |
Posted - 2011-06-29 : 05:00:32
|
Without looking it up or checking, I don't think you can have a table name starting with a numeric character i.e. 005. It might work if you put it in square brackets though although you seem to have changed the table name in your later version.If you're trying to populate the column with a date and time of import you can use GETDATE() or CURRENT_TIMESTAMP. not sure what the difference is between these two to be honest as the output looks the same.---------------------------------------------------------------------------------http://www.mannyroadend.co.uk The official unofficial website of Bury Football Clubhttp://www.hollowtreewebdesign.co.uk - a web design company in its infancy |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-29 : 05:10:11
|
quote: Originally posted by theboyholty Without looking it up or checking, I don't think you can have a table name starting with a numeric character i.e. 005. It might work if you put it in square brackets though although you seem to have changed the table name in your later version.If you're trying to populate the column with a date and time of import you can use GETDATE() or CURRENT_TIMESTAMP. not sure what the difference is between these two to be honest as the output looks the same.---------------------------------------------------------------------------------http://www.mannyroadend.co.uk The official unofficial website of Bury Football Clubhttp://www.hollowtreewebdesign.co.uk - a web design company in its infancy
The only difference between GETDATE() and CURRENT_TIMESTAMP is that CURRENT_TIMESTAMP is in ansi standard and GETDATE() is not. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|