About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).
Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Tuesday, April 03, 2012

Quick Tip: Importing images into a database from SSIS


To have SSIS upload to the database, in your data flow task, add a "Import Column". Set the "Input Columns" as the image file path, and the "Output Columns" as a image datatype. In SQL-Server, the field just needs to be an "image" type, when doing a data flow destination.












Thursday, May 21, 2009

Link Server limited return row size from Informix

So I ran into the following error while trying to run a query.

"Maximum output rowsize (32767) exceeded"

The problem with this, was that I was using a SQL SERVER link server, called ETS, to an Informix database. The problem was that I could not limit the size on the "Notes", so basically I ended up using an exec and open query just to accomplish this task.



declare @Query varchar(max)

set @Query = N'select

wrkhdr.region_no,

notif.atten,

notif.dba,

notif.owner,

notif.addr1,

notif.addr2,

notif.city,

notif.state,

notif.country,

notif.postal_code,

notif.notif_id,

notif.notif_date,

notif.start_date,

notif.end_date,

wrkhdr.create_user,

wrkhdr.rid,

wrkhdr.license_no,

notif.license_status,

rtrim(CAST(notes.note as nvarchar(250)))

FROM

notification notif

join workq_hdr wrkhdr ON wrkhdr.workq_id = notif.workq_id

left join document_header ON document_header.filing_id = wrkhdr.filing_id

left join document_header_notes ON document_header.recno = document_header_notes.document_header_notes_id

left join notes ON document_header_notes.notes = notes.note_id

where notif.notif_id = ' + convert(varchar(30),@Parameter1)

set @Query = N'select * from openquery(ets2, ''' + REPLACE(@Query, '''', '''''') + ''')'

exec (@Query)

Tuesday, August 21, 2007

Interview question: What structure would you use to represent shapes in a database?

OK, A few months ago, my friend told me of an interview question that I found interesting. The question that was given to him, paraphrasing: "If you had to set up a database to hold shapes, what would your table structure look like?". The point of the question was for him to convert the concept of a class shape that might be used in an object oriented language to be converted to a database structure. Which is why I was stuck on this question, with no simple straight forward solution.

I then started thinking about this question, again. The idea of the question was to see what tables and columns would you set up to make this feasible. I wanted an easy solution with minimal work, so I avoided the polymorphism concept and went to a simpler definition of a shape (polygon).

I figure I would make 1 table called SHAPE with 2 columns and make the assumption that the shapes are defined as "simple polygons":


ID int, COORDINATES varchar





The ID is obviously the primary key for each shape.


The Coordinates is a order list of Cartesian coordinates going counter-clockwise.

Now, given a shape, the most common questions asked would be what is the perimeter and area of said shape. I could easily make 2 store procedures to find the perimeter and area.

To figure out the perimeter, I just need to add up the distance from each point, simple enough.

To figure out the area of the polygon, I knew there had to be a formula that would do this for me, and thanks to wikipedia I found one:





"The formula was described by Meister in 1769 and by Gauss in 1795. It can be verified by dividing the polygon into triangles".


I was looking around, to see if others seen this question. I did find something similar at http://lists.mysql.com/mysql/207823

If I needed to query the table for certain shapes, then it would be good to add an additional column called: Points int

So, if I needed to query the table for triangles only then I can do a search on points = 3.