Categories
SQL Server

Handling comma-delimited lists as stored procedure input

Comma-delimited lists can be used as input to stored procedure, assuming their length is predictable.
Handling them inside the body of the stored procedure, is not a native matter (no FOREACH construct) and requires minor programming.
For example, using an input variable called @sad_date:


WHILE (LEN(@sad_date) > 0)
BEGIN
-- extract the string at the head of the list
SET @commaPos = CHARINDEX(',', @sad_date);
IF (@commaPos > 0)
BEGIN
SET @dateStr = SUBSTRING(@sad_date, 1, (@commaPos-1));
SET @sad_date = SUBSTRING(@sad_date, (@commaPos+1), LEN(@sad_date));
END
ELSE
-- we reached the last substring
BEGIN
SET @dateStr = SUBSTRING(@sad_date, 1, LEN(@sad_date));
SET @sad_date = '';
END
--
-- do something with the input here....
---
END

Share
Categories
SQL Server

Checking if a table exists in your SQL Server 2000 database

So you want to check, before you declare, or do anything special, whether a table exists in your database. This is important when you want to update more than one database instance and are writing a script. To do that run the following test:

IF EXISTS (select * from sysobjects where id = object_id(‘[name_of_your_table]’))

Share
Categories
Computing Java Web Development

Setting up jEdit for remote development using SSH and sFTP

I am taking a class about XML and XSLTat the Harvard Extenion.
We are supposed to essentially remotely log into the system through SSH and use emacs or any other editor of our liking for the development of our projects and solutions.

I am totally down with emacs but the fact that it does not have XSlide or any other context-sensitive helper functionality enabled on the server is disappointing. So I tried NetBeans, Eclipse and finally jEdit as alternatives with the following requirements:

1. Must be able to save and read file remotely using sFTP (FTP is not enabled on the server).
2. Must be useful with XML.
3. If possible, also allow to log in to the system using an internal SSH client.
4. Anything I use must be free and legal.

NetBeans is supposedly very good with XSLT. I did not get that far because it does not have internal sFTP or SSH.

Eclipse has a really cool sFTP plugin that allows you to synchronize to a remote folder using the ‘Team’ functionality. But its XSLT support is way limited and the free version of XML Buddy does not support it. It also can only SSH when it involves CVS. I could not find anything to decouple the two… probably need to write one myself.

jEdit, my favorite left-field option and definitely not as chi-chi as the other two, had all three.
It has so-so XSLT support.
It has internal sFTP support that virtually mounts the remote file system into jEdit’s own file manager. Very cool.
Finally, it has an available (surprisingly not through its plugin manager) SSH client that you need to download and install into the $home/.jedit/jars folder. If you do follow this advice, note that when you connect, the window that should pop up to request your user name and password does not really pop up but pops under so just notice any new windows appearing.

jEdit wins.

Share
Share