September 27, 2013
Tokenizing T-SQL
Ran accross this example of using the SQL-Server parser to tokenize a T-SQL script, statement, what-have-you.
At my company, we have some very specific SQL Formatting Standards. And we have not found a code formatter that can do the job. We've just come up with a VS2012 Add-on that bridges the gap between the formatting that SQL Prompt Pro does and what our standard requires. But, there are problems. I got to thinking, if there were a way to parse the T-SQL and then use the resulting Tokens as the basis a T-SQL formatter may not actually be that tough to create.
This is the best article I found. It turns out that you've got a parser available through .NET. Now, if I don't lame out on the idea, I might just try some C# code to format some T-SQL. Who knows. Might be the beginning of a codeplex project. Or a successor to our SQL-Prompt-Pro-plus-homebrew-plugin solution.
September 09, 2013
Data-Tier Application Framework (DACFx): What Version is installed
Method One: Uninstall Programs
- Go to Uninstall Programs on the control panel.
- Search for Data-Tier
- See the version number.
- Run regedit
- Find this registry key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\DACFramework\CurrentVersion
- From there, look at the Version value.
May 30, 2013
Creating a Windows Installer on USB Drive
http://www.microsoftstore.com/store/msus/html/pbPage.Help_Win7_usbdvd_dwnTool/
Don't worry that the tool has Windows 7 in the name. It works for Windows 8 too.
October 08, 2012
Team Foundation -- Oops, I shouldn't have checked that in!
> tf rollback ...from the command line.
Then, I found the setting in Visual Studio to propmt on check-in.
Menu:
Tools > OptionsOptions dialog:
Source Control > Visual Studio Team Foundation Server > Prompt before check-in from Pending Changes windowI checked the option. And now I get a confirmation before checking in.
The cool thing is that the change type in history shows 'edit, rollback'. I also updated the initial changeset's comment to include a note about the rollback and the rollback changeset id.
VS Studio 2010 Database Projects
Initial Thought on VS Database Projects
Meta-model
Best Dev practices
Some interesting possibilities
References
March 07, 2012
Providing Metadata to SSIS dataflows
IF 1=2 SELECT CAST(NULL AS...), CAST(NULL AS ...) ...This was the very first statement in a long complicated SQL script that eventually...way down at the end of the file...after hundreds of lines...selected a result set that would be used in a SSIS dataflow.
Oh, this must be nonsense, I thought. Let me ask if I can take this out. There is no reason to have an if that tests a contradiction (the opposite of tautology is, which is what we have here).
Well there is a good reason why the contradiction had to be there and I couldn't remove it.
SSIS must determine what columns are coming into it. It does this by looking at the first select in the SQL script and assuming that the columns and datatypes it sees there are what will flow into it. So, in this very complicated script, the IF 1=2 statement must be there.
If the sql script were simply a single select statement, the fake first select wouldn't be necessary since SSIS could get its result set metadata from the one-and-only select statement.
Clearing Up My SSL Noob Questions
January 05, 2012
Find out what is causing CPU use in SQL Server
exec admin.dbo.usp_serverblocks @orderby = 'secprocessortime'
December 21, 2011
In Javascript, || and && don't evaluate to a boolean
Truthy-ness (and falsy-ness)
An expression is "truthy" if it isn't "falsy". The "falsy" values are
- false (the boolean literal value)
- "" (the empty string)
- undefined
- null
- NaN (The special number value, representing not a number)
- 0 (that's the number, not the string)
And because of this interesting absurdity, such a snippet may just destroy the world.
Enough with the truthy-falsy, get on to the operators already!
So, again, <expression1> || <expression2> will return ....
the result of <expression1> if it evaluates to true, else, the result of <expression2>.
So, false || undefined evaluates to ... undefined.
undefined || "Hi!" evaluates to "Hi!"
You can use this to default the value returned from an expression.
someValue || 5.0 ... will evaluate to 5 if someValue is undefined. But if someValue is boolean false, it will also do that. As it will with other defined values. so maybe be careful. You would probably only intend for 5 to be defaulted if someValue===undefined.
Inverse to the behavior of the || operator is that of the && operator. && returns the first operand (left one) if it is falsy, else it returns the second.
Confused Yet?
If you are...well so was I. I would refer you to a lecture by Douglas Crockford, it will clarify and teach you some amazing things about javascript.
Finally:
Here is an example I setup on jsfiddle.net.
December 08, 2011
Javascript with operator is bad
VirtualBox/USB - Community Ubuntu Documentation
I had to add myself to the vboxusers group and then vbox could connect to usb devices. I was able to let other programs access usb without starting the program as root too. So I still need to understand how the group and the bus permissions are linked. But I'm glad to be able to share USB devices with my Virtual Machine.
March 24, 2011
My Code Fixes: Runtime Class and Method information
With that thread you can call getStackTrace(). This allows you to get the current class and method name from stackTrace[0] (stackTrace being the result of getStackTrace()).
You, of course, have to be in a context where this code executes on the same thread.
Thanks to Ryan Sukale.
My Code Fixes: Runtime Class and Method information
April 06, 2010
Ubuntu 9.04 PDF Printer (You have to create the PDF directory)
I looked in the ubuntu documentation. I'll quote the part of the article that referenced the problem.
however, on the 9.04 machine I had to create the /home/your_user_name/PDF folder manually for each user on that machine to allow the PDF "printer" to work. Before I did so, when opening the "Printer Properties" window for the PDF "printer" I saw the following:After executingPrinter State: Idle - /usr/libs/cups/backend/cups-pdf failed
So if you can't find your output and see the above status, make sure that the PDF folder exists in the home directory of the current user.
mkdir PDFfrom my home directory, printing started to succeed. PDF documents began to appear in my new PDF directory.
December 18, 2009
Enable Classic Eclipse Update Capability
In the preferences dialog, search for Capabilities.
In /General/Capabilities, check 'Classic Update'.
Restart and the classic update and plug-in management is available.
December 01, 2009
Hibernate's "User SQL Comments" feature causes a problem with DB2
I've been having a problem where a query sent through hibernate fails with the message: executeQuery method cannot be used for update
Here is an example of the log output. The hibernate actual hql and sql queries have been replaced with [...] in order not to expose my employer's database schema information.
Hibernate: /* select [...] */ select [...]JDBCExceptionReporter:100 - SQL Error: -99999, SQLState: nullJDBCExceptionReporter:101 - executeQuery method cannot be used for update.
I googled: db2 "executeQuery method cannot be used for update"
and the second result lead me to this.
It turns out that the problem was that I had the hibernate property "hibernate.use_sql_comments" set to "true". This caused the error because the hql was prepended to the sql query. Once I commented out the setting of that property the problem went away. I suppose that the default is false for this property.
I copy and paste the material here just in case it disappears from the referenced page.
Hibernate problems and solutions
- Hibernate not retrieving entity and throwing (what seems) a jdbc driver exception.
I have a simple entity mapping and attempt to save and then retrieve the object by the generated id. Hibernate throws the following exception:
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not load an entity:
[nz.co.client.blitztecapp.model.MessageArchiveImpl#41]; uncategorized SQLException for SQL [/* load nz.co.client.blitztecapp.model.MessageArchiveImpl */ select messagearc0_.MESSAGE_ARCHIVE_ID as MESSAGE1_0_0_, messagearc0_.MESSAGE_TYPE as MESSAGE2_0_0_, messagearc0_.CONTENTS as CONTENTS0_0_, messagearc0_.MESSAGE_ID as MESSAGE4_0_0_, messagearc0_.PACKAGE_ID as PACKAGE5_0_0_, messagearc0_.CREATED_BY as CREATED6_0_0_, messagearc0_.CREATED_DATE as CREATED7_0_0_ from MESSAGE_ARCHIVE messagearc0_ where messagearc0_.MESSAGE_ARCHIVE_ID=?]; SQL state [null]; error code [-99999]; executeQuery method cannot be used for update.; nested exception is com.ibm.db2.jcc.a.SqlException: executeQuery method cannot be used for update.
Caused by: com.ibm.db2.jcc.a.SqlException: executeQuery method cannot be used for update.
at com.ibm.db2.jcc.a.co.a(co.java:2079)
at com.ibm.db2.jcc.a.cp.d(cp.java:1528)
at com.ibm.db2.jcc.a.cp.K(cp.java:316)
at com.ibm.db2.jcc.a.cp.executeQuery(cp.java:299)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3042)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:467)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:369)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:461)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:455)
.
.Problem:
The problem is a hibernate property that I had set : hibernate.use_sql_comments=true causes the failure. This seems to be a bug in hibernate - Unset the property and things should work fine.
November 25, 2009
DB2 9.7 JDBC Driver causes a problem for hibernate native id strategy
App Server: IBM Websphere Application Server 6.1
DB: IBM DB2 8.?
JDBC Driver: Those packaged with IBM DB2Express v9.7
I would get a message stating:
org.hibernate.HibernateException: The database returned no natively generated identity value
When I changed my Websphere server configuration to point to an older db2 jdbc driver, the insert succeeded.
Information and workaround options are available here.
October 12, 2009
DB2 install and config tutorial
October 08, 2009
In Ubuntu, sh is dash, not bash
unlink /bin/sh
ln -s /bin/sh bashafter doing this the installer worked just fine.
Should you desire, you can switch back to dash. Just run the above commands substituting 'dash' for 'bash' in the second one.
Here is more information on the sh-as-dash 'feature' of Ubuntu.
September 24, 2009
Aptitude (Command-line package manager)
aptitude update -- update the package repo
aptitude safe-upgrade
aptitude full-upgrade
aptitude search 'part of package name'
aptitude show package-name
aptitude install package-name
Switching Linux Consoles
Ctrl-Alt-F8 brings up some text, maybe system messages or something but it doesn't look like a command line I can do something with.
A little research suggest nothing runs on Terminals 8-12 initially.
Adding key to apt so ppa packages can be authenticated
Add the source to Ubuntu (System > Administration > Software Sources)deb http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty mainAdd the project signing key to apt:
deb-src http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty main
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 095F1873
The signing key from launchpad was 1024R/095F1873 (note the part after the slash is used in the apt-key command.
The ppa page from which I got this information:
https://launchpad.net/~keepassx/+archive/ppa?field.series_filter=jaunty
Adding key to apt so ppa packages can be authenticated
deb http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty mainas sources.
deb-src http://ppa.launchpad.net/keepassx/ppa/ubuntu jaunty main
Then I added the corresponding key to apt with this command:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 095F1873095F1873 is part of the PPA's PGP signing key (1024R/095F1873)
September 04, 2009
Trapped in Terminal Server Client Full Screen
The key sequence Ctrl-Alt-Enter toggles full screen.
September 02, 2009
Killing processes in linux
ps ax | grep notes
to get the process id and then run
sudo kill -9
to kill it.
Tyler, a coworker, pointed out to me that I could add 'Force Quit' to the panel at the top. When you press that you can just click on a misbehaving window to kill it.