Showing posts with label integers. Show all posts
Showing posts with label integers. Show all posts

Monday, March 12, 2012

Integers, Money values becoming zeros

Hi,

When I reset the SQL query in Database ->Show Sql Query, all integer and money type values are becoming zeros. When I execute the same query in the SQL Query Analyzer I am getting the values with same no. of records in the report. Can anybody suggest me the solution.

The only difference before resetting, the query doesn't have "WHERE" clause.

Thanks in advance.Post the query you used and the table structure

Integers in SQL Server

I'm having a problem with the way integers are stored internally and how they are returned with a SELECT statement. In the project I'm working on, I have to move data from an Excel file to a database so I'm using DTS and a group of stored procs to pull this off. What happens is:
    DTS pull data from Excel into temp tables Stored proc pulls from the first temp table into a supertype table IDENTITY column assigns primary keys Stored proc then loads primary keys into a cursor and, starting with the LAST record, moves the PK into the appropriate subtype table and assigns the correct foreign key enteries. Next stored proc pulls data from the second temp table into the supertype tabel Repeat process until all data is stored
I'm starting with the last record so I know that it will be from the most recent transfer from a temp table. Unfortunately the order of records that the cursor returns is not the order that they were inserted into the database. So when I go to transfer the records with PK numbers 258 and 257 (the last 2 inserted into the supertype) I end up moving the records with PK's 204 and 203 (the last 2 in the cursor). Is there any way to sort the records as they go into or come out of the cursor so the smallest number is first and the largets number last? Also, there are probably a thousand ways to do this more efficiently so suggestions there are also welcome. Thanks
I think I figured out a solution that doesn't use cursors and won't be affected by internal storage issues. However, comments and ideas are still welcome.|||Having staging table(s) is a very good thing when it comes to data import/export. If you can, try to eliminate dts from the process to save some cpu cycles. You'd want to look up linked server/openquery/openrowset/opendatasource in book online/google for some details.

Integers & dynamic allocation

Here is what I am trying to do...
I want to goup "members" togethers in a "group."

A table for members and a table for groups.

each containing coluns...

but inside Groups I would like a column that contains ID numbers for the members that be long to that group.

Being that members can belong to multiple groups - I can not use a GroupID in Members - if so I also need a way of it modular.

Obvisiously I am not a very good DB programmer - but I want the least amount of empty/unused space in my tables.

Hope this makes senseyou need a third table (tblMemberGroups) that contains two columns

MemberID and GroupID

this table allow any member to belong to any number of groups and give you a normalized database structure (no wasted space).

you would need to create joins between all 3 tables to determine group membership

members -> tblMemberGroups -> groups