Tuesday, August 21, 2007
Server: Msg 4712, Level 16, State 1, Line 1
Cannot truncate table 'actTouches' because it is being referenced by a FOREIGN KEY constraint.
To get around this problem I simply delete all rows from the table then re seed the identity column with 1.
Delete From [table]
DBCC CheckIdent ([table], RESEED, 1)
Identity columns are commonly used as primary keys in database tables. These columns automatically assign a value for each new row inserted. But what if you want to insert your own value into the column? It's actually very easy to do.
The trick is to enable IDENTITY_INSERT for the table. That looks like this:
SET IDENTITY_INSERT IdentityTable ON
INSERT IdentityTable(TheIdentity, TheValue)
VALUES (3, 'First Row')
SET IDENTITY_INSERT IdentityTable OFF
Here are some key points about IDENTITY_INSERT
* It can only be enabled on one table at a time. If you try to enable it on a second table while it is still enabled on a first table SQL Server will generate an error.
* When it is enabled on a table you must specify a value for the identity column.
* The user issuing the statement must own the object, be a system administrator (sysadmin role), be the database owner (dbo) or be a member of the db_ddladmin role in order to run the command.
Read the full article for more information. For instance the fact that this can modify the identity properties of your column depending on the values you update the table with.
Monday, August 20, 2007
Select top 1 * From [xxx.xxx.xxx.xxx].[db].[owner].[table]
In SQL2005 Management Studio against a SQL2000 box.
And receiving this:
An error occurred while executing batch. Error message is: Processing of results from SQL Server failed because of an invalid multipart name "xxx.xxx.xxx.xxx.db.owner.table", the current limit of "4" is insufficient.
I was unable to link the servers by name since there was no DNS to resolve it.
I finally discovered that I didn't receive the error if I simply used SQL 2000's Query analyzer. I was a little surprised to find that this issue in backwards compatibility existed in the Management Studio. I have not had a chance to test a SQL 2005 linked server to see if an IP address causes the same issue on it, though I would hope that it wouldn't.
Note: I just discovered that I was able to use OPENQUERY in Management Studio to run my query from one SQL2000 server to a linked SQL2000 server.
SELECT * FROM OPENQUERY([xxx.xxx.xxx.xxx], 'SELECT * FROM [db].owner.[table]') AS tablename
Tuesday, August 14, 2007
Monday, August 13, 2007
tar xvf something.tar
If the tarball has also been gzipped (compressed), you can use the following command:
tar xvfz something.tar.gz
The biggest thing that I always forget when trying to use this command is that it doesn't accept the "-" prefix before its modifiers like most other linux commands.
If you need to create a tar file
tar -cvzf name.tgz subdirthe 'z' is optional and gzips the file.
the 'v' is optional and gives a verbose output.
Wednesday, August 8, 2007
Excerpt from another page I found helpful:
So, dynamically added controls must be programmatically added to the Web page on each and every page visit. The best time to add these controls is during the initialization stage of the page life cycle, which occurs before the load view state stage. That is, we want to have the control hierarchy complete before the load view state stage arrives. For this reason, it is best to create an event handler for the
Initevent in your code-behind class, and add your dynamic controls there.
Note You may be able to get away with loading your controls in theShortcut Summary:
Page_Loadevent handler and maintaining the view state properly. It all depends on whether or not you are setting any properties of the dynamically loaded controls programmatically and, if so, when you're doing it relative to the
line. A thorough discussion of this is a bit beyond the scope of this article, but the reason it may work is because the
Add()method recursively loads the parent's view state into its children, even though the load view state stage has passed.
1. Object Initialization
2. Load Viewstate Data (void LoadViewState( object o ) )
3. LoadPostData Processes Postback Data
4. Object Load (void onload(EventArgs e) )
5. Raise PostBack Change Events
6. Process Client-Side PostBack Event (void RaisePostBackEvent (string eventArgument) )
7. Prerender the Objects
8. ViewState Saved (void RaisePostDataChangeEvent() )
9. Render To HTML
10. Disposal (void OnPreRender( EventArgs e ) )
Tuesday, August 7, 2007
|-||0 or 100 (*)||Default||mon dd yyyy hh:miAM (or PM)|
|6||106||-||dd mon yy|
|7||107||-||mon dd, yy|
|-||9 or 109 (*)||Default + milliseconds||mon dd yyyy hh:mi:ss:mmmAM (or PM)|
|-||13 or 113 (*)||Europe default + milliseconds||dd mon yyyy hh:mm:ss:mmm(24h)|
|-||20 or 120 (*)||ODBC canonical||yyyy-mm-dd hh:mi:ss(24h)|
|-||21 or 121 (*)||ODBC canonical (with milliseconds)||yyyy-mm-dd hh:mi:ss.mmm(24h)|
|* The default values (style 0 or 100, 9 or 109, 13 or 113, 20 or 120, and 21 or 121) always return the century (yyyy). |
** Input when converting to datetime; Output when converting to character data.
CONVERT (data_type[(length)], expression [, style])
Monday, August 6, 2007
Friday, August 3, 2007
Wednesday, August 1, 2007
Warning: It does try and connect to the internet when run for some unknown reason.