This is more of a database driver error but I encountered it within a datawindow I was working on so PB gets credit. I was working on a generic data drill down control which has a filtering process to eliminate data based on a date argument. Since I also wanted this date value for other…
You are currently browsing all posts tagged with SQL Server
PowerBuilder ‘Gotcha’ – Column lists do not match
Sending iCalendar events via a .Net Assembly and SQLServer stored procedure
As I’ve mentioned in earlier posts, the iCalendar format is a standard way to send event information to a variety of email/scheduling systems (Outlook, Google, etc.). Here is a way to set it up so that you can simply call a stored procedure to send the event. This assumes you have SQL Server set up…
PowerBuilder – SQL Native Client and DisableBind
Okay so you are upgrading your application, perhaps using the latest version of PowerBuilder (12.5) and SQL Server (2008 R2), and decide to use the SQL Native Client (SNC) to take advantage of new features in the database. Now like many organizations which use Microsoft SQL Server, you may have gone to OLE DB in…
SQL Server Identity Columns – Inserting and Resetting
So I wanted to test a scenario against a database table which had no rows, even though there were several currently in the table. Easy you say, just copy the data into a ‘backup’ table, delete the rows, run your tests, then copy the data back. Well not so fast when you have an IDENTITY…
Calculate the Last Day of the Month
Here is how to calculate the last day of the current month. Powerbuilder date ld_eom ld_eom = RelativeDate(Date(String(Month(Today()) + 1) + "/1/" + String(Year(Today()))), -1) SQL Server SELECT DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, Getdate()) +1, 0)) I quess SQL Denali has a new function (EOMONTH) to do this too. SELECT EOMONTH(GETDATE())
Joining to a Table Function in SQL Server
Following up on my previous post, SQL Server (since version 2005 while in SQL 90 compatibility mode) provides the ability to join to the table created by a parameterized table function. In earlier versions you were not able to use a table function with a dynamic parameter or even join to it. If you needed…
Splitting up a String or Text in SQL
Here is a way to split up a block of text and return a result set based on a delimeter. A table function is used to do the ‘heavy lifting’ and, utilizing some newer features of SQL Server (2005 and 2008), you can even join to it providing for even greater flexability. This situation I…
PowerBuilder ‘Gotcha’ – SQLServer OLE DB and Identity columns
So I get a new machine at work and I’m busy loading all my development tools on it as well as changing settings and all such stuff. SQL Server and PowerBuilder get installed and upgraded, connected to Source Control, and I run the application from within the IDE. Things are fine until I insert a…
Sequence Numbers in SQL
Here is a link to a very good article on SQLServerCentral.com showing a technique to re-sequence items via a database stored procedure rather than on the client. It’s pretty straight forward and solves a fairly common issue I’ve addressed several times in PowerBuilder over the years.
Update Columns in Database
It’s pretty common to want to update a column (or several columns) in one table with the value(s) from another table. Here is how to do it: UPDATE Table SET Table.col1 = other_table.col1, Table.col2 = other_table.col2 FROM Table INNER JOIN other_table ON Table.id = other_table.id WHERE … The structure of this syntax is always something…