Multiple Data Types In One Table With Nulls

Sep 25, 2013

Our database stores vehicle data in one table, but 3 different types of data are stored in the one table. The table contains all the columns for all 3 types so when you query the table you get at least 3 rows back with null values for all the columns that don't apply to that record. The data is imported to the table when it's updates so there's a possibility that they're updated at different times so they have a different BATCH like:

BATCH TYPE ID RATING INSURANCE SAFETY
300 SAFE 123 NULL NULL A
300 INS 123 NULL YES NULL
250 RATE 123 A NULL NULL

What I'd like returned is:
ID, RATING, INSURANCE, SAFETY
123 A YES A

I'm trying to do a case statement to pull the data down, but I keep ending up with multiple rows because of all the nulls. I tried doing a SUM of the case statement with an ISNULL(SAFETY,0) but I can't SUM char values. I can probably do this with 3 temp tables to load the data that I want for each TYPE into them and then select and join them together, but is there a better way to do this?

View 2 Replies


ADVERTISEMENT

Multiple NULLs In A Table

Apr 5, 2004

To make the long story short, we have a situation where there can be different datatypes for a column. For example, 'AttributeValue' can be a datetime, int, float etc. My DBA is suggesting the following design,

tblAttribute

AttributeId, AttributeDataTypeId, AttributeValueInt, AttributeValueFloat, AttributeValueDateTime etc

For any AttributeId, only one of the value columns will have a value and the rest will be NULLs. I feel that this is a bad design. (FYI, We decided against SQLVariant for specific reasons). I have suggested, we create a seperate table for each datatype, like

tblAttribute: AttributeId, AttributeDataTypeId

tblAttributeValueFloat: AttributeId INT, AttributeValue FLOAT
tblAttibuteValueDateTime: AttributeId INT, AttributeValue DATETIME
etc for each datatype.

Depending on the AttributeDataTypeId in the Attribute table go to the specific table and pick up the value. This way, we don't need to have too many NULLs in a row. Which of the 2 do you think is a better design? And if you agree with me, what would be the points to support it.

Your time is greatly appreciated

View 7 Replies View Related

Multiple Types Of Data Storing In SQL Server

Mar 22, 2007

Hello All,

We are developing customer support application. We will have so many customers after launching this product. But my problem is how will i store data of all these customers in SQL Server. Please suggest me.

View 1 Replies View Related

Report Designer - Multiple Font Types In A Single Table Cell

Jan 24, 2008

Does anyone know if it is possible to have text in a single table cell where the first field is formatted in italics and the second is in normal?

eg: = Fields!firstname.Value(as italic) & " " & Fields!lastname.Value(as normal)?

shidot

View 5 Replies View Related

Inserting Data Into Table - Column Does Not Allow Nulls

Sep 26, 2013

I'm inserting data from a c# webservice into a table via a stored procedure, but I get a Column does not allow nulls on the @alert_id column/field. It is set as int and allow nulls is not ticked.

Here's the sql:

USE [aren]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [aren1002].[ArenAlertInsert]

[Code] ....

View 7 Replies View Related

Reporting Services :: Table Data Types For Data Driven Subscriptions

Jun 11, 2015

I am trying to find a reference for a client that lists the fields available to be substituted into a data driven subscription from the query, along with the expected data types.  For example, the field on whether or not to include a link to the report seems to be expecting a bit data type.I have searched and can't seem to find anything.  I guess I could walk through the interface and try different data types, but if  a list exists, that would be better. 

View 4 Replies View Related

CURSOR And TABLE As Data Types?

Oct 1, 2013

I consider CURSOR and TABLE as data types but some one has argued that these are database objects.

View 7 Replies View Related

One Or More Columns Do Not Have Supported Data Types, Or Their Data Types Do Not Match.

Oct 20, 2007



Hi,

I´m exporting an ms-excel file, then I use a lookup transformation to get a field from a SQL Server 2005 table. The Lookup transformation editor, after selecting the table, shows a warning that says:

at least one mapping between a column from available input columns ans a column from available lookup columns must be defined on the columns page.

So I try to make a relationship in the Lookup transformation editor's column tab where I find the Available input columns and the available lookup columns but I get the following error:

The following columns cannot be mapped:
[Department, DEP_CLEGALCODE]
One or more columns do not have supported data types, or their data types do not match.

The field in SLQ Server is varchar(10) and the input field is a derived column transformation; I have tried different Data Types but I always have the same error.

The DataFlow is: ExcelSource --> Derived Column --> Lookup --> Flat file destination

thanks.

View 6 Replies View Related

Table Data Types In SQL Server 2000

Jan 24, 2005

Hi,
Can anybody give me some information on Table data types of SQL2K.
How and where can it be used. Does it make the queries faster, in case there are many users using ?
Please could anybody give me these details, to make me decide whether I can use it or not ?

Thanx and Regards,
Sushma

View 1 Replies View Related

Listing Table Data Types Using TSQL

Jun 17, 2008

I can find out the data types used in my table by navigating the SSMS and right clicking the table and selecting modify.

How do I view that same output using T-SQL?

Thank you
Goldmember

View 1 Replies View Related

SQL Server 2000 Table Data Types

Jul 20, 2005

Hi,Can anybody tell me if it is possible to return a table data type (asopposed to a temporary table) from a stored procedure.I am currently studying for 70-229 using the Thomas Moore book but itdoesn't really make it clear, as the text suggests you can't returnthem but some of his sample questions suggest you can.I can't make it work in Query Analyser so I am assuming that you can'treturn them. Is that correct?Thanks in advance for any help,Simon.

View 1 Replies View Related

Copying Data From One Table To A New One With Some Different Data Types

Mar 30, 2007

Is it possible to easily copy data from one table to another if the data types don't match.   I know you can do a INSERT INTO table1(col1,col2)  SELECT (col2,col7) FROM table2 if the data types match but is there a way to do this if they don't. I'm not trying to copy date times into bit fields or anything.  I just have an old table that I built when I really didn't know what I was doing now I at leastthink I have a better understanding of what data types to use, so I was wanting to move the data in the orignal table to my new one.  Most of the fields in the olddatabase are text datatypes and the new database is nvarchar(50) data types.  Thanks for any suggestions. 

View 4 Replies View Related

Flat File Data Types - Defined From Table?

Jul 3, 2007

This question is around how we can get the data types and lengths populated into the flat file source columns.



In Connection Manager, you have your flat file defined. You can choose "Suggest Types...", and the minimum lengths and correct data types will be returned from within the data in the flat file.



Is there some way to automate this data type definition, but coming from the other direction (coming from the destination table that we are loading)?



For example, you have mapped the columns that will be loaded. Can you then reverse engineer the data types and lengths for the columns in the flat file from the destination table?



TIA

View 5 Replies View Related

Binary Data Types (Images) In Matrix/Table Items In Reports

Jul 11, 2007

I am trying to produce a matrix (crosstab) report in SQL Server 2005 Reporting Services Report Designer, where the column headers contain a binary data type storing a png image.

By just simply using the report wizard and assigning the binary (image) data value to the column headers, and then previewing the report, I get following error:



An error occurred during local report processing.An error has occurred during report processing.The Group expression used in grouping 'matrix1_COMPETITOR_EMBLEM' returned a data type that is not valid.




Is there any way to include binary data types, or images per se from the database into a matrix or even table item in a report ?

View 3 Replies View Related

Updating Datetime Data Types In A Table To Show Just Day, Month, Year

Apr 2, 2008

I have a table with a datetime field 'TheDate'. Currently dates are stored as 'mm-dd-yyyy 00:00:00'. Is there a way to get just the month, day and year parts, '01/01/2008' into the field without changing the field data type to varchar? I'm asking because when I do this:


declare @MyDate as datetime

set @MyDate = '04/02/2008 18:00:00'

select substring(convert(varchar,@MyDate,101),1,10)

I get '04/02/2008', but when I do this:

update TheTable
set TheDate = substring(convert(varchar,TheDate,101),1,10)

I'm still getting a date in the format 'mm-dd-yyyy 00:00:00' stored in the table. I'd like to be able to lose the time portion, but I'd like to be able to keep the datetime datatype for date math purposes. Can it be done?

View 4 Replies View Related

Reseeding Temporary Tables Or Table Data Types With Identity Column

Feb 17, 2006

Hi,

I have a indexing problem. I have a sequence that needs to has a index number. I want to use a table data type and have a working sample BUT I cannot reseed the table when needed. How do I do this.

This works only for the first ExitCoilID then I need to RESEED.



Here is my code:



DECLARE

@EntryCoilCnt AS INT,

@ExitCoilID AS INT,

@SubtractedFromEntyCoilCnt AS INT

DECLARE

@ExitCoilID_NotProcessed TABLE

(ExitCoilID int)



INSERT INTO @ExitCoilID_NotProcessed

SELECT DISTINCT ExitCoilID

FROM

dbo.TrendEXIT

where

ExitCoilID is not null and

ExitCnt is null

order by

ExitCoilID



DECLARE

@ExitCoilID_Cnt_Index TABLE

(ExitCoilID int, ExitCnt int IDENTITY (1,1))

IF @@ROWCOUNT > 0

BEGIN

DECLARE ExitCoilID_cursor CURSOR FOR

SELECT ExitCoilID FROM @ExitCoilID_NotProcessed

ORDER BY ExitCoilID

OPEN ExitCoilID_cursor

FETCH NEXT FROM ExitCoilID_cursor

INTO @ExitCoilID

WHILE @@FETCH_STATUS = 0

BEGIN

INSERT INTO @ExitCoilID_Cnt_Index

SELECT ExitCoilID

FROM dbo.TrendEXIT

WHERE

ExitCoilID = @ExitCoilID

ORDER BY

EntryCoilID, Cnt

select * from @ExitCoilID_Cnt_Index

--truncate @ExitCoilID_Cnt_Index

--DBCC CHECKIDENT ('@ExitCoilID_Cnt_Index', RESEED, 1)

FETCH NEXT FROM ExitCoilID_cursor

INTO @ExitCoilID

END

CLOSE ExitCoilID_cursor

DEALLOCATE ExitCoilID_cursor

select * from @ExitCoilID_Cnt_Index

END --IF @@ROWCOUNT <> 0

View 8 Replies View Related

Creating Clustered Index On View With Table Containing XML Data Types Takes Forever And Causes Timeouts

Apr 21, 2007

I am trying to create a clustered index on a View of a table that has an xml datatype. This indexing ran for two days and still did not complete. I tried to leave it running while continuing to use the database, but the SELECT statements where executing too slowly and the DML statements where Timing out. I there a way to control the server/cpu resources used by an indexing process. How can I determine the completion percentage or the indexing process. How can I make indexing the view with the xml data type take less time?



The table definition is displayed below.



CREATE TABLE [dbo].[AuditLogDetails](

[ID] [int] IDENTITY(1,1) NOT NULL,

[RecordID] [int] NOT NULL,

[TableName] [varchar](64) NOT NULL,

[Modifications] [xml] NOT NULL,

CONSTRAINT [PK_AuditLogDetails] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

) ON [PRIMARY]



The view definition is displayed below.



ALTER VIEW [dbo].[vwAuditLogDetails] WITH SCHEMABINDING

AS

SELECT P.ID,D.RecordID, dbo.f_GetModification(D.Modifications,P.ID) AS Modifications

FROM dbo.AuditLogParent P

INNER JOIN dbo.AuditLogDetails AS D ON dbo.f_GetIfModificationExist(D.Modifications,P.ID)=1



The definition for UDF f_GetModification



ALTER function [dbo].[f_GetModification]( @Modifications xml,@PID uniqueidentifier )

returns xml

with schemabinding

as

begin

declare @pidstr varchar(100)

SET @pidstr = LOWER(CONVERT(varchar(100), @PID))

return @Modifications.query('/Modifications/modification[@ID eq sql:variable("@pidstr")]')

end





The definition for UDF f_GetIfModificationExist



ALTER function [dbo].[f_GetIfModificationExist]( @Modifications xml,@PID uniqueidentifier )

returns Bit

with schemabinding

as

begin

declare @pidstr varchar(100)

SET @pidstr = LOWER(CONVERT(varchar(100), @PID))

return @Modifications.exist('/Modifications/modification[@ID eq sql:variable("@pidstr")]')

end



The Statement to create the index is below.



CREATE UNIQUE CLUSTERED INDEX [IX_ID_RecordID] ON [dbo].[vwAuditLogDetails]

(

[ID] ASC,

[RecordID] ASC

)WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

View 1 Replies View Related

Unique Key&#39;s And Multiple NULLS?

Jul 10, 2001

Hi,

I have 3 columns that I'd like to set as a key, however I do have multiple instances of NULLs for all 3 columns. Thus when I try to create the key, it stops because there are multiple instances of NULLs. I looked at using procedure that check each entry made into the table, but I couldn't figure out how to deny an INSERT/UPDATE request. Anyone have any better methods of implimenting the unique key?

Ilya

View 3 Replies View Related

Unique Which Allows Multiple Nulls

Jul 16, 2006

Hi,
I have a non-cluster index on the filed, I need to make it non-cluster index and unique which allows multiple nulls, how should I do this with an sql statement?

View 6 Replies View Related

T-SQL (SS2K8) :: Selecting Data From Table With Multiple Conditions On Multiple Columns

Apr 15, 2014

I am facing a problem in writing the stored procedure for multiple search criteria.

I am trying to write the query in the Procedure as follows

Select * from Car
where Price=@Price1 or Price=@price2 or Price=@price=3
and
where Manufacture=@Manufacture1 or Manufacture=@Manufacture2 or Manufacture=@Manufacture3
and
where Model=@Model1 or Model=@Model2 or Model=@Model3
and
where City=@City1 or City=@City2 or City=@City3

I am Not sure of the query but am trying to get the list of cars that are to be filtered based on the user input.

View 4 Replies View Related

Problem With A Join Due To Multiple Nulls

Mar 29, 2006

I want to join 2 tables by a unique ID field, but the ID field also hasmultiple NULLS which I do not want to ignore and I fear they will causeduplication.Using TableA and TableB below i will demonstrate the problem.TableATableA.ID Field1 Field21 Paul 1Null John 12 John 1TableBTableB.ID Field3 Field41 25 1Null 32 1Null 23 12 26 1The Table I want isTableA.ID TableB.ID Field1 Field2 Field3 Field41 1 Paul 1 25 12 2 John 1 26 1Null Null John 1 Null NullNull Null Null Null 32 1Null Null Null Null 26 1I think a select distcinct statement with a full outer join may do whatI want, but I'm not certain so want to check.Regards,Ciarán

View 10 Replies View Related

Unpivot Multiple Columns With Datetime NULLs

Apr 3, 2007

Hi there,

I'm trying to unpivot a table in SSIS: The pivoted table basically looks like

ID DATE1 TEXT1 DATE2 TEXT2

----------------------------------

ID1 D1 T1 D2 T2

...

The unpivoted result looks like

ID DATE TEXT

-------------------

ID1 D1 T1

ID1 D2 T2

€¦



It works, but the one problem I am facing is: If D1 IS NULL in the pivoted table then D1 in the unpivoted table contains some strange value that is neither NULL nor a valid datetime. In a data viewer I get the in the DATE field "Fehler: Die Parameter Year, Month and Day beschreiben eine nicht darstellbare Datetime." (i. e. "Error: The parameters Year, Month and Day form an invalid datetime."). The loading of the OLE DB target yields an error because the DATE value cannot be converted to a valid datetime.



Anybody having a solution to this?

View 6 Replies View Related

Integrity Across Multiple Database Types

Jul 8, 2005

Since most use SQL server, I thought I would post the question here.Is it possible, or is there a product or DBMS that enforces referential integrity across multiple databases and database types? Such as SQL Server, Oracle, etc...Thanks,Zath

View 2 Replies View Related

Multiple Types Of Info In One Query?

Sep 21, 2006

Hi,

I am trying to display a report from a bug tracker that shows the number of issues logged per month, per year and how many issues have been closed in that month. I have no difficulty displaying the number of issues that have been logged within a particular months, but when I need to display the number of issues closed - I get stuck. I am calling from one table 'bugs', which contains date_reported, status_id. I can do a count on the number of bugs between certain dates but I cannot list the number of closed issues in that exact time. I get the feeling I need a select statement within a select statement? If anyone can help. Thanks

View 3 Replies View Related

Multiple Record Types In One File

May 14, 2007

I have a text file to import where there are three file types: a header which has info about who sent the file and begins with 'H', detail records that begins with D and a trailer record that begins with T and just has the record count following that. The fields are delimited by '*'. H, D and T records each contain a different number of fields.
I suspect that what I should do is to split this file into three separate files. I tried to do this with SSIS but ran into problems. If I make the output a file destination, it won't let me use that output as input for the next process. There are no arrows I can grab onto to link to the next transform.

This is my first SSIS package although I made hundreds of DTS packages a few years ago. I can't figure this out in DTS either.

This sounds like it should be an EASY thing to do.

View 3 Replies View Related

Multiple Record Types Same File

Sep 27, 2006

A flat file I must parse has multiple record types in the same file that must be processed together. For instance, in the following example:

01TestStuff888
02TestStuff2
03TestStuff3
01TestStuff4
02TestStuff5

Each 01 record type has the records after it associated to it until the next 01 appears, so TestStuff would have TestStuff 2,3 related to it while TestStuff 4,5 belong together. In the example the 888 in the 01 record is the key to the group, but it does not appear in the following lines.

The problem is that each record type has different line formats, columns, etc, so they must be parsed differently. I have created a conditional branch on the first two characters, and written each record type out to a seperate flat file for that type, so that they can be imported again and parsed with the Flat File Source, but I am unsure how to relate them again. I tried appending the 888 to the other lines before they were written out, but I can't find a way to share the variable across the conditional split branches using a script component.

Does anyone have an idea how I could parse these files and keep the relationship intact?

Is there a way to tell the flat file wizard to use a different map based on certain characters?

Is there a way to share a variable across the different braches of a conditional split.

Strange question I know, but thanks for any help.

Travis

View 4 Replies View Related

Return Value Based On Record With Multiple Types

Jan 15, 2015

I want to return Order records which are one type and don't have the other type.

The issue is I have Orders with which has 2 distriubtion types .

Example
Order 12345 has Type S and Type X.
Order 67891 has Type S

I only want to return Order 67891 that are s Type and does not have type X

View 1 Replies View Related

Transact SQL :: Update Multiple Table Referencing New Table Data

Aug 4, 2015

I have a table called ADSCHL which contains the school_code as Primary key and other two table as

RGDEGR(common field as SCHOOl_code) and RGENRl( Original_school_code) which are refrencing the ADSCHL. if a school_code will be updated both the table RGDEGR (school_code) and RGERNL ( original_schoolcode) has to be updated as well. I have been provided a new data that i have imported to SQL server using SSIS with table name as TESTCEP which has a column name school_code. I have been assigned a task to update the old school_code vale ( ADSCHL) with new school_code ( TESTCEP) and make sure the changes happen across all 3 tables.

I tried using Merge Update function not sure if this is going to work.

Update dbo.ADSCHL
SET dbo.ADSCHL.SCHOOL_CODE = FD.SCHOOL_Code
FROM dbo.ADSCHL AD
INNER JOIN TESTCEP FD
ON AD.SCHOOL_NAME = FD.School_Name

View 10 Replies View Related

Creating Hierarchical Flat File From Multiple Record Types

May 1, 2008

I'm using SSIS to import seven flat files (each containing a different record type) into a staging database. This part was easy.

Now I need to export the records from all seven tables into a single flat file structured in a nested hierarchy using common keys. (This format is required by the vendor for loading data into a new system).

I could use some ideas on the data transformations needed to combine all seven record types into an hierarchical record set which can then be written to my Flat File Destination. I'm currently looking at an article on SLQIS.com ("Handling Different Row Types In The Same File") which seems close to what I need, but they are importing (ref: www.sqlis.com/54.aspx ). I'm not sure if I should just reverse this for export or use something different. Any comments are appreciated.

Diagram of Record Hierarchy

typeA (parent key, ...)

typeB1 (parent key, childSet key, date, ...)

typeB2 (parent key, childSet key, ...)

typeC (parent key, childSet key, ...)
typeD (parent key, childSet key, ...)
typeE1 (parent key, childSet key, date, ...)

typeE2 (parent key, childSet key, ...)


The record types B1 through E2 form a complete set. Each set has it's own unique child-set key. There may be one or more sets for each typeA record (although it's possible that typeE records don't exist in the most recent set).

View 3 Replies View Related

Destination File With Multiple Record Types And Sequences - Mainframe-like

Jul 20, 2007

Howdy all,



I've seen several posts about reading and writing files that have different record types with varying column metadata. My particular file has 11 record types plus several header types and looks something like:



<Header1>

<Header2>

<Detail01-#1>

<Subdetail02>

<Subdetail03>

...

<Detail01-#2>

<Subdetail02>

<Subdetail03>

...

...



Since i need to get different detail and subdetail records, i can't really use the technique of 3 dest file connection managers found in http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=87269&SiteID=1



I've tried using an exec sql to get the main detail records and then a forech ADO en umerator that would get the subdetails, but it all seems so kludgy. I'm starting to think that I should just write the bulk of the file creation code in a c# app instead of trying to smush this into SSIS. Opinions? Am I missing some trick in SSIS?



TIA,



-Peter

View 7 Replies View Related

Column Allows Nulls I Want To Change No Nulls Allowed

May 16, 2006

When i do a select on my emplee table for rows with null idCompany i dont get any records

I then try to modify the table to not allow a null idCompany and i get this error message:

'Employee (aMgmt)' table
- Unable to modify table.
Cannot insert the value NULL into column 'idCompany', table 'D2.aMgmt.Tmp_Employee'; column does not allow nulls. INSERT fails.
The statement has been terminated.

This sux

View 4 Replies View Related

Removing Nulls From Table Help

Aug 4, 2006

Hi,
What sql would I use to remove all the nulls in a table?

thanks!

View 11 Replies View Related

Multiple Data From Same Table?

Jun 18, 2007

I need to get the total reps by total and active status for the last 30 days.

There are two tables: Orders, and Customers. Orders just has the order date while customers has type and status columns.

Total: Customers.Status = any, customers.type = 'distributor'
Active: Customers.Status = 'Active' customers.type = 'distributor'

how would i do a sum on these two for the same report when both of the sums use different values?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved