Sql Types - Simple SQL Server Queries/handling Variable Types

May 26, 2005

SQL Server 2000, ASP.Net 1.1

I've been writing this stuff for a while, and can't seem to come to the
conclusion of how I should be retrieving data and assigning this data
to variables.

Since i'm using SQL Server, I'm convinced that I should be using the
datareaders GetSqlDouble (or whatever) function, but this would mean i
need my local variables to be one of the SQL types.  The problem
with that is, that there will have to be lots of conversions done by me
to be able to use a SQL type in my application.

For instance, I have a class where i'm retrieving dates.  In order
to retrieve them correctly (Null values included), I need to retrieve
them with GetSqlDateTime(), then when it comes time to display the date
in a table, i must first check for nulls, then convert to a
string.  This seems to be very cumbersome.  Would I be better
off just using GetDateTime(), and the .ToString method, and ignoring
Sql Types all together?

so, basically, how are you guys using your sql server data?  with
the supplied sql types, and doing all of the post-processing work
manually?  I feel like i'm having trouble conveying my
issue...hopefully someone knows what i mean....i'd just like some
direction to save trouble in the long run, since i feel like there's
got to be a better way...

Confused!

Thanks,
JJ

View 1 Replies


ADVERTISEMENT

SSIS - Handling Different Types Of Record In Same Flat File Source

May 10, 2006

Hi,

I've just started looking at SSIS and have encountered what should hopefully be a simple problem to solve. I have a pipe-separated source file that looks like this (I've added Line numbers for simplicity):

Ln 01: HDR|FEED_CODE|31-MAR-2006
Ln 02: Tom|100|Jones|ZZ1 1ZZ|USA
Ln 03: Tom|200|Singer|
Ln 04: Tom|305||Red|Porche ||Lanzarote |Apple|Carrot| | |
Ln 05: Dick|100|Van Dyke|ZZ1 1ZZ|USA
Ln 06: Dick|200|Actor|
Ln 07: Dick|305||Blue|Ford||California |Tomato | |||Beef
Ln 08: Harry|100|Houdini|ZZ1 1ZZ|GBR
Ln 09: Harry|200|Escapologist|
Ln 10: Harryk|305| |Green ||Triumph |Poland|Banana|Sprout| | |
Ln 11: TRL|9


In addition to a header and footer records, this file contains three record types for each person.

Record types are identified by the second column.

Each record type has a different number of columns:

Type 100 has 5 columns
Type 200 has 4 columns
Type 305 has 12 columns

The Row delimiter for all records is the {CR}{LF} character

I've set up a flat file input source and specified {CR}{LF} as the row delimiter for both header and data rows and the "|" character as the field delimiter.

It appears that SSIS is assuming that because the first data row has 5 columns, then everything must fit that format too. So the {CR}{LF} character that separates lines 02 and 03 is interpreted as text rather than a separation character and all remaining | field separators after 305 are interpreted as text containing in the fifth column. SSIS is also complaining that the last row is incomplete.

A bit like this (I've used tildes to indicate column separation):

Tom~100~Jones~ZZ1 1ZZ~USA
Tom~200~Singer~{CR}{LF}Tom~305||Red|Porche ||Lanzarote |Apple|Carrot| | |

I've seen one other reference to this behaviour but the response seemed to be SSIS doesn't know which columns are missing. In this scenario, we don't have missing columns, rather, we have different types of record in a single file. in DTS I would effectively parse the file once for each record type thus:

if cStr(DTSSource("Col002")) = "100" then

DTSDestination("in_Name") = trim(DTSSource("Col001"))
...

Main = DTSTransformStat_OK
else
Main = DTSTransformStat_SkipInsert
end if


...not the most efficient solution I know but the load only runs once a month so this was an acceptable workaround.

DTS was never this fussy but I'm sure this is user error rather than an SSIS limitiion. Can someone please put me straight?

Many thanks,

Greg

View 7 Replies View Related

Desperate! - Need Simple MSSQL Server Monitoring Scripts, Ideas, Etc That Can Be Performed By Operator Types (non-programmers)

Jul 20, 2005

Does anyone have any basic, simple scripts of sp's that I can give mycomputer operators to use to monitor for serious conditions on our sqlservers? We are new in the ms-sql arena, a small shop and we cantreally purchase any tools to monitor these servers, but we need somebasic checks that we can use to make sure a server is performing in areasonable fashion, no blocks, cpu<xx%, memory not pegged, IO working,etc...and we need to be able to do this without bugging ourprogrammers every time we are wondering why things are slowwnig down.We are a split shop between as400s and sql servers, and our operationsstaff has no problem performing this type of duty on the 400s. I thinksince the sql servers are so easy to deploy into production, the ideaof how to monitor these things health got lost in the shuffle andallowing the programmers to do it just serves to destabilize ourenvironment.Please help! Our shop has turned to chaos since we went live withMSSQL centric applications and everytime one programmer "resolves anissue" some other programmers application starts to act up.

View 6 Replies View Related

Table Variable And User Defined Types

Oct 30, 2003

This is part of the codes of a stored procedure:

-- Create tables variables
DECLARE @_tab_PRNumList TABLE(
PRNum udt_PRNum
)

However, it cannot be compiled coz of this error:
Error 2715: Column or parameter #1: Cannot find data type udt_PRNum.

This user-defined data type is created in a user database only.

I tried to created the user-defined type into BOTH tempdb and master but same error.

How can i resolove it?
Or it is impossible to use user-defined datatype for table variable?

In the past,
i use this method:
CREATE TABLE #PRNumList (
PRNum udt_PRNum
)

and cerate udt_PRNum in tempdb only could solve it.

But now i want to use table variable.
It seems NOT work for my situation.

Any idea?

View 1 Replies View Related

Changing Data Types Of A Variable In An Expression

May 18, 2006

Greetings once again SQL friends,

Sorry to bug you with my silly questions but this little problem has been driving me crazy for the last hour or so!

I am attempting to change the data type of a variable in an expression but I keep getting an error saying that the expression can not be evaluated.

The syntax I am using is as follows :

(dt_str) @[User::MAX_OFFER_PRICE_ID]

My variable MAX_OFFER_PRICE_ID is type int32 and I am attempting to cast it as a string.

What am I doing wrong?!

 

Thanks for your help in advance.

View 7 Replies View Related

Help Passing Complex Variable Types To A Web Service Task

Feb 23, 2007

I need a little help here and appreciate any insight into this issue.

I am building an SSIS package that retrieves data from a database to use in a web service task. So let me give you a little more broad overview of the package so you can understand how this is supposed to roll. A database is queried and those values are dumped into a recordset. A foreach loop uses each row of variables to call the web service and dump the returned values to another database. The first database holds a bunch of fields, but the four fields of interest are: a StartDate (DateTime), a StartFormat (single char), an EndDate (DateTime) and an EndFormat (single char). The output from the query of the first database is the input in the signature of a web service's .Load method. Sounds easy, right? Sure, why not?

Well I dragged the Web Service Task on to the pane and took a look inside. Lo and behold, I can hardcode the variables in for the web service or I can assign the inputs to package variables. How fancy, thanks Microsoft!

But that's where the difficulty begins. The method call for the web service looks like this: service.Load(string, int, GTTimestamp1, GTTimestamp2). The web service is expecting a string, an int, and two objects of the type GTTimestamp, which is a very simple class defined as this:

<System.Xml.Serialization.SoapTypeAttribute("GTTimestamp", "http://util.gtdw.pci.com")> _

Public Class GTTimestamp

Public calendar As Date

Public displayFormat As String

End Class

In the input pane for the Web Service, when I click in the value of the two GTTimestamps like I'm going to hardcode them in, another window pops up saying "Enter the values for complex type -in4" and the pane looks exactly like the previous pane with one very important exception: There is not place to check to assign the value from a package variable!!! Dang you Microsoft!!! I don't really understand why they would leave us out to dry on this... Oh, well, maybe they'll take care of it later...Time to work around it.

SSIS does allow you to create a variable of type System.Object, so after playing with the Web Service for a few minutes and giving up on that, I decided to create a script task that is supposed to create two GTTimestamp objects and assign them to two object variables in the package for passing to the WebService Task. The first challenge was to get the web service to play nice with the script. For those who have never done this, use a command prompt and the wsdl.exe to generate a .vb or .cs file to add to your script file using the right click, add existing item...

Once the file was accessable to my scripts, I created two GTTimestamp objects and assigned them to the Package variables of type System.Object. Running the package, I got this error:

"Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException: Could not execute the Web method. The error is: Type 'ScriptTask_8c868490237b4220b582bdc7c7a3ecae.GTTimestamp' in assembly 'VBAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Not marked as serializable, huh. Okay, so I made the GTTimestamp serializable by adding the <Serializable()> before the class declaration. Then the error changed to:

The error is: Type is not resolved for member 'ScriptTask_8c868490237b4220b582bdc7c7a3ecae.GTTimestamp,VBAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

And here I am, at a loss for what to do from this point. I'm a little lost, so I thought I'd stop and ask for directions. I'm sure I'm not the first to want to use complex variable types.

Only two options at this point. One is to try and store the GTTimestamp in the database and see if SSIS can deal with that. I'm not sure how to store objects in a database or if that is even an option for me, but it came to mind so it made it into this post. The other is to get this to work through the script above that I have run into a wall.

Again, any help is appreciated. Thanks for your time.

View 11 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

Data Types In SQL Server

Oct 11, 2005

I'm new to SQL Server, but could someone explain how to set up a field with an auto number/increment that can be used within an Access DB?

View 4 Replies View Related

Sql Server && Col Data Types

Jan 13, 2004

I am trying to write a generic stored procedure to return the data type of a given col in a given table in any database.

I would like to place this sp in master.

input parms are @TableName sysname and @ColName sysname
ouput parm is @data_type varchar(128)

set @data_type=''
select @data_type = data_type from information_schema.columns where table_name = @TableName and column_name = @ColName

when debugging this I always get 0 rows (@data_type remains '')

I have a thought that I can add an input parm for the database, say @DbName sysname
But I am having trouble updating the select stmt to be something like
...from @DbName +'.' + information_schema.columns.

Any Ideas?
Thanks for your help.

View 9 Replies View Related

SQL Server Data Types

May 25, 2006

Very simple ...

Where can I find a web site that explains the difference between sql server express data types?

thx.

View 3 Replies View Related

Default Data Types In SQl Server

Feb 2, 2006

Is there a way to change the default data type in SQL Server? If I import a database into SQL Server it makes every non-numeric field a nvarchar field. Is there a way to change this so that these fields would be varchar or char by default? I cannot find any way to redo these as a batch/group update and have to modify every single field manually. Any insights greatly appreciated.

View 4 Replies View Related

Confusion With SQL Server Database Data Types

Jan 17, 2007

I trust you'll bear with an SQL Server newbie with what may seem a rather inane request. I am designing a web app in Web Designer 2005 Express with SQL Server Express. Unfortunately, I'm finding a little confusing with some of the data types when designing tables. I have tried to find information on the various Microsoft sites (general site, MSDN, here) and while I found one document that had a table comparing data types in different implementations of SQL, it wasn't at all helpful. Most of my confusion is with the various string and char types; the numeric types seem pretty straight forward for the most part. However, it might be helpful to know the difference between money and smallmoney/datetime and smalldatetime, particularly space/size information and formatting options (unless the latter is up to the interface).  It would also be helpful to know which string/char types correspond to any counterparts they might have in, for instance, Access (with which I am already quite exprienced). Or any particular quirks or idiosyncracies they might have. I don't expect anyone to write a full tutorial, but if someone could point me in the direction of a good online doc, it would be most appreciated.  You might well ask, why not use Access databases? I would answer...I like to learn new stuff!
Thanks much.

View 4 Replies View Related

Saving Various File Types To SQL Server 2005

Apr 29, 2007

hello,I am building a web page in asp.net 2.0 and i'm looking for a way to save various files uploaded by users (such as doc, pdf, cs, txt .... whatever). Obviously the normal way would be to store it on the filesystem of the web server (or any other middleware server).But I am asking if there is a way to store these files in the database, and not affect too much of the performance of the web page?I know a picture can be stored easily, but what about all the other file types?  I would appreciate if someone can spead light of the subject.Thanks,Tranquil. 

View 1 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

SQL Server 2012 :: Join On Different Data Types

Jun 11, 2014

We have a query that joins column A int which is an int onto column B with contains only int's but was created as a varchar and can't be changed to an int at the moment.

Casting column a as a varchar in the ON of the join to left join seems to void the index altogether and the query just runs for every.

We are talking a few hundred million rows of data in each table.

Temp solution is select into a #Hash table as correct data type and index then use the #Hash table in the join.

View 6 Replies View Related

Create View In SQL Server With Data Types

Aug 14, 2006

I need to create a view of a sql table, but change the data types. I knowthe syntax below is not correct, and can't figure out if it is wrong or ifyou just can't do this. I have only created views before with the same datatype.CREATE VIEW F0005New(DRKY nchar(3), DRDL01 nchar(30))INSERT (SELECT rtrim(F0005.DRKY), F0005.DRDL01FROM F0005 AS F0005WHERE DRSY = '41' AND DRRT = 'S1')Thanks!!

View 4 Replies View Related

Mapping SQL Server Data Types To C DataTypes

Jul 20, 2005

Hi Can anyone point me to a document somewhere that shows a mapping ofSQL Server 2000 datatypes to C datatypes? I am writing some extendedstored procedures which need to be able to process pretty much anydata type, so I want to make sure I am taking them from SRVPROC andstoring them in the correct C data type.Thanks,Bruce

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

SQL Server Data Types For Local Variables

Jul 20, 2005

Is there ANY data type other than varchar that is valid for localvariables and allows more than 8000 characters?

View 3 Replies View Related

SQL Server 9.0 (2005) &&amp; PostgreSQL Data Types

Jan 5, 2006

Hi,

I´m building an aplication with VB.net and SQL Server 9, but in the future it will be compatible with PostgreSQL (by another developer), so my question is, if anyone knows what "data types" in SQL Server 9 i must use to maintain compatibility with PostgreSQL, so that when the time come for the conversion i don t have to chage the "Data Types" on each table.

Any help would be apreciated.

View 4 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

Default Values For SQL Server Data Types

Jul 12, 2007

Hi,

I need to populate some SqlParameter but I temporarily need to populate with a default value for the data type in question. Of course I can work them out, but I was wondering if there is already a way of doing this, from the .Net Classes or from SQL Server but without making a trip to the DB.

Thanks

John

View 1 Replies View Related

How To Handle Text, Ntext Data Types Of SQL Server

Jan 8, 2004

i have created asp.net page, one feild of this page text area.
when i insert some text through this page in "text feild" of SQL server on few words of this feild cut and inserted to text feild of SQL server but all text that i have written in text area feild.

can u please help me how to handle so that i can all text in text feild of SQL server data type text/next.

View 2 Replies View Related

SQL Server 2008 :: Build A Query That Put Different Types In Columns

Jun 5, 2015

I have 3 tables, a supplier table, a types table and a relationship table between the two..I want to build a query that put the different types in columns, and use a Boolean value to identify if the supplier supplies that type.

CREATE TABLE #Suppliers(
id INT,
nam NVARCHAR(50)

[code]...

It's possible to do this in "one" query?

View 2 Replies View Related

Importing Decimal Data Types Into SQL Server 2005

Apr 4, 2006

I have a simple Integration Services project and the problem is that decimal fields are importing as real (I'm loosing the digits behind the decimal point).

The project contains a data flow task importing a flat file (.csv) to an SQL Server destination. My .csv file has two decimal type fields. Example:

Field 1: 12345.67

Field 2: .123456

My database table that I'm importing to has two fields. The only way that I can get this data to import is to define the fields as "float" in both the text file and database table. I want the database table fields to be defined as decimal or numeric, not float:

Field 1: decimal(7,2)

Field 2: decimal(6,6)

When all fields are defined as decimal (in both the flat file and database file), I get the following results:

Field 1: 12345.00

Field 2: .000000

How does one import decimal data from a flat file (.csv)?

Thank you in advance!

View 1 Replies View Related

Migrating Oracle PL/SQL Objects And Collection Types Into SQL Server 2005

Mar 7, 2008



Hi

Can anyone help me out in migrating Oracle stored procedures & Functions which contains collection types (user-defined datatypes like VARRAYS) into SQL Server 2005. How to achieve this taks? This is very important for me and it's very urgent. Please someone help me.

Thanks & Regards
K P Kumar

View 1 Replies View Related

SQL Server 2000 Requires Explicit Declaration Of Data Types In Client App After Installing A Certain HotFix

Jun 15, 2004

I think I may have figured out the solution to my recent conundrum with SQL Server 2000 that had me stressed and depressed over the last couple of days. In a nutshell, after a HotFix was installed on a SQL2K database server I have space on, I was unable to perform INSERT or UPDATE queries on database table of type TEXT, when trying to either create or modify records with more than 4,000 characters of data. While it was frustrating as heck, it seemed too rigid to be random, so I did some snooping.

The HotFix was intended to solve a known problem of not being able to run UPDATEs against TEXT fields, but in so doing, caused another headache entirely: http://support.microsoft.com/?kbid=839523

Apparently this is a semi-known problem, in that a certain HotFix forces SQL Server 2000 to be a lot more stringent in requiring explicit declaration of data types and data lengths for parameters in stored procedure. In my client code, I was initially using the overloaded constructor of the SqlParameter object that took as arguments only the parameter name and a value, without specifying a value from the SQLDBType enumeration or length of the parameter (which in my case, needs to be TEXT and 16 (or 2147483647), respectively):

System.Data.SqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@parameterName",parameterValue);

It appears that after the HotFix is installed, if the client doesn’t syntactically set the type and length of data for a parameter, SQL Server and/or .NET will default to a type of NVARCHAR, which has the 4,000-character limit. This all makes sense. I’m going to now need to modify the code to straight out declare what’s going in the SPROC:

System.Data.SqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@parameterName",SqlDbType.Text);
System.Data.SqlDataAdapter.InsertCommand.Parameters["@parameterName"].Value = parameterValue;

It’s a minor change, and it sucks that I have to make it after the code had worked flawlessly over several thousands executions over several months, but c’est la vie! Better thay than have to rebuild my DB from scratch or switch to a new server. Changing the client code evidently is the only known fix at this time: http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b827366

View 1 Replies View Related

SQL Server 2005 - Transactional Replication Involving Depricated Text And Ntext Data Types

Dec 2, 2005

I'm currently trying out transactional replication with updatable subscriptions across two 2005 servers.

View 3 Replies View Related

How Many Types Of UDF Are There?

Feb 4, 2006

Hi,
Please help me to know this question.
How many types of UDF are in SQL SERVER 2000?
Please tell me if anybody knows the answer.
Thanks in advance,
Joydeep

View 14 Replies View Related

SQL Types

Mar 13, 2004

HI i have a big problem i have an exericse to do on SQL for school but i havne tbeen told what they are. All i have to do is to match the follwing togehter and say why they would use it any ideas?

DDl-

DML-

DCL-

these need to be matched up to certain users:

Database administartor

Users

Application develpers any ideas

View 2 Replies View Related

About Sys.Types

Nov 29, 2007

in my work I use some "objects", that i tune using "Parameters"
So i have table MyObjects And ObjectParameters-OP
In the table OP i want field for Parameter Type(Type)... now i using type Varchar(63) and then i need for parameters of money type, i will get it by SELECT * FROM ObjectParameters WHERE Type = 'money'...
at the sql.ru i got an answer, where they suggest me using type "sysname", in MSDN i have found that it is equivalent nvarchar(128), i a cant find any differences between my solution and sql.ru solution.

AND main question is.. can i using ID for my types from View sys.types, And can i be sure that it will be the same ID in another version SQL Server (like 2000, 2008) or another installation of SQL Server for same type...

sorry if i have misstakes in my english...

Thanks In Advance...

View 6 Replies View Related

Object Types In SQL

Jun 2, 2007

Hi,
 When creating a database in the Management Studio, you get to select the database owner, and should that be usually the Administrator and ASPNET account?Also, what is this Object Types option for? There seem to be only one "Login" option in there, what does that serve as?

View 2 Replies View Related

License Types

Sep 21, 2007

i want to check the price of sql server 2005 in my country as a consideration to take when deciding on wich db to build.i dont understand the licensing method. what 5 clt stands for ? whats the basic 64 bit 1 processor dual core license i need for a commercial website ? thanx, 

View 1 Replies View Related







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