Monday, March 26, 2012
Need function for padding
I am using Format function in my query when I was using access tables.
Now I have imported my tables in Sql server and linked through odbc. Now in my query it throws message for "Format" function. I tried for Replicate function but still not able to get this problem.
Same case for Date and chr.you need to use convert or cast, not format.|||it sounds like you are doing SQL Passthrough in jet against sql server, and now you need to use SQL Server syntax instead of jet/access sql.'
cheers|||Originally posted by eisoffind
Hi
I am using Format function in my query when I was using access tables.
Now I have imported my tables in Sql server and linked through odbc. Now in my query it throws message for "Format" function. I tried for Replicate function but still not able to get this problem.
Same case for Date and chr.
If i understand your question correctly, you want to be able to pad the left of a number with another value. For example '555' --> '000555'
Attached are two SQL2K UDFs to lpad and rpad.sql
Need feedback on my plan to import a terribly formatted Excel spreadsheet
Good morning, all,
I have an Excel workbook that needs to be imported. It has three
sheets, but it's really the first that is giving me fits. Each of the
three worksheets have header info and instructions on the first 8
rows. Worksheet 1 then has, on row 9, the column names for the group
informtion. Row 10 has the group information. Row 11 has detail
column headers. Row 12 and later have detail information. Worksheets
2 and three do not have detail information, just row 9 with the column
names for the group informtion and Row 10 with group information.
Here is how I am thinking of handling this.
Run a script, outside of SSIS to save each sheet as a CSV file to a
folder. I believe that this must be done because some of the first 8
rows are blank and according to the docs, SSIS cannot have blank rows
in imported Excel sheets.
Loop over the files in the folder.
For each file, exclude the first 8 rows.
if the file name is the first worksheet then
get the next two rows and process group info
get the rest of the worksheet and process detail information
if the file name is not the first worksheet then
get the next two rows and process group info
My questions are: Does this seem feasible? Is there an easier way to
do this? Any hints or tricks that might be helpful? Any pitfalls
that I should watch out for?
Thanks so much for any insights,
Kathryn
It sounds like you have two record types to import, group and detail. I would load the data into a staging table designed to handle both or multiple record types as a first pass. Once the data is loaded to the staging table, you can pass through the table and load each record type into separate tables and process from there.
However, your approach should work as well.
Friday, March 9, 2012
Need a way to switch specific data from columns
so I'm trying to write a stored procedure that would switch the first name with the date of birth wherever the firstname is purely numeric, or something of the sort.
If you have an ID column all you would need to do is check if there are multiple records (count(*)> 1). if so keep the first one (min(id) or whichever you choose), delete the rest, get the two values into local variables and update the record in hand.
if you already made an attempt post some code and we can help you out.