Converting DT_STR To DT_BOOL
May 28, 2008
Can anyone tell me how to convert a string variable to boolean
Ihave a variable named VarLoc which is string datatype
In expression I want to give condition like
VarLoc == "1234"?False:True
its giving error because of converting string datatype to boolean.
Please help.
Thank You
View 3 Replies
ADVERTISEMENT
May 16, 2006
Anyone know the origin of sql 2005's datatype naming convention or even why SSIS has defined its own special data types? (Before SSIS I had never seem types like DT_UI1 except in programming languages.)
TIA,
barker
View 1 Replies
View Related
May 15, 2006
Okay, this is probably my own stupidity but here goes. I am trying to make a very rudimentary package. I've got a data flow that has a flat file source. This source has fields delimited by the | symbol. I give the fields in the flat file source names. The first field is always exactly 1 character. When I use the advanced editor to look at the fields' properties, I see the first field, called ProductLine, is considered to be of SSIS internal data type DT_STR with a length of 50. I change the 50 to 1 because that is as long as that field is.
No matter what I do, when I close the advanced editor and then open it again, the field length for ProductLine is again set to 50. The field is 1 long, not 50 long. How can I make the setting of 1 be retained? Nothing I do changes it. What is the point of allowing the length to be editable if the edit is not retained?
Thanks in advance,
SW
View 4 Replies
View Related
Apr 26, 2007
I have a OLE DB Source going to a flat file destination. My source is a sql variable with "select * from tablename" which have varchar datatypes. Yet I'm getting trailing spaces at the end of some of my columns (for instance, my address column).
I've checked the data by doing a "select Max(Len(address)) from tablename" and the max is only like 34 chars, yet each of them have 100 chars total.
Taking a look at my flat file connection, the outputColumnWidth is 100, and datatype is string [DT_STR]. Am I crazy? What's the problem here? Is the DT_STR datatype the equivalent of char, and not varchar?
Any help, of course, will be appreciated.
View 8 Replies
View Related
Mar 30, 2007
Our shop's DTS packages usually use ActiveX scripts to dynamically name vendor text file inputs by date (YYYYMMDD), which we load Monday through Friday to our databases. For our 2005 server I am trying to dynamically name a 'flat file source' filename in SSIS as described in the article at the url http://www.mssqltips.com/tip.asp?tip=1084.
I am writing the expression (DT_STR, 4,1252) YEAR(DATEADD( "dd",0, getdate() ) to create a variable named FileName to capture today's 4 character year. If I could get a good preview of this value I would concatenate the month and day strings to it and use the resultant variable as part of the fully qualifeid name.
For the variable I've marked the 'evaluateasexpression' true and put the value type as str. But when I preview this expression I get the error message, 'expression has the result type of DT_STR which can not be converted to a supported type.'
What supported type? Does anyone see what the problem is?
View 9 Replies
View Related
Dec 18, 2007
Hi,
Having problem with OLE-DB connection to informix.
Created a flat file has two columns and 2 row:
1|a
2|b
tried to load it to a informix table:
create table t
( c1 int,
c2 char
);
2 rows inserted, but only column c1 got data.
Changed c2 from char to varchar then ok.
thanks for any help.
gg
View 17 Replies
View Related
Dec 27, 2007
Hi, I am trying to derive a column from:
mm/dd/yyyy hh:mms.fff to dt_dbtimestamp as:
(dt_dbtimestamp)(colum_name,1, 23) when I include the period and three digits for milliseconds the package fails if I leave it out it is successfull. I need to include milliseconds for my datawarehouse project. I tried many different ways and always with failure
01/23/2007 12:23:15.234 is the date(example) derived: (dt_dbtimestamp)(column_name,1,23) fails
01/23/2007 12:23:15.234 is the date(example) derived: (dt_dbtimestamp)(column_name,1,19) succeeds
Thanks
View 9 Replies
View Related
Oct 9, 2006
The Lookup Transformation fails to match this datatype when full caching is enabled. When partial caching is activated (Edit > Advanced, Enable Memory Restrictions > Enable Caching) the lookup works.
This appears to be a bug to me.
View 4 Replies
View Related
Sep 16, 2006
Hi all I am trying to convert the string "(null)" in the [PASSWORD] column of my table to an actual NULL value. I have tried to use two different forms of a conditional operator to achieve this end. However I am getting the below errors both can be summed up with the following statement.
DT_STR operand cannot be used with the conditional operation. The expression directly below however is using a type DT_I4 in the conditional clause as this is what FINDSTRING returns. Hence the equivalencey test to the literal integer 0. So I must say I am somewhat confused by this. Does anyone know why neither of the below statements are working?
Also is there an easy way to accomplish what I am trying to do - convert the string "(null)" in the [PASSWORD] column of my table to an actual NULL value?
FINDSTRING([PASSWORD], "(null)", 1) == 0 ? [PASSWORD] : NULL(DT_STR, 255, 1252)
Error at Administrator Data Flow Task [Derived Column [1985]]: For operands of the conditional operator, the data type DT_STR is supported only for input columns and cast operations. The expression "FINDSTRING(PASSWORD,"(null)",1) == 0 ? PASSWORD : NULL(DT_STR,255,1252)" has a DT_STR operand that is not an input column or the result of a cast, and cannot be used with the conditional operation. To perform this operation, the operand needs to be explicitly cast with a cast operator.
LOWER( TRIM( [PASSWORD] ) ) != "(null)" ? [PASSWORD] : NULL(DT_STR, 255, 1252)
Error at Administrator Data Flow Task [Derived Column [1985]]: For operands of the conditional operator, the data type DT_STR is supported only for input columns and cast operations. The expression "LOWER(TRIM(PASSWORD)) != "(null)" ? PASSWORD : NULL(DT_STR,255,1252)" has a DT_STR operand that is not an input column or the result of a cast, and cannot be used with the conditional operation. To perform this operation, the operand needs to be explicitly cast with a cast operator.
View 4 Replies
View Related
Nov 8, 2006
I have a select statement like this:
select IsVerified from AppForm
the IsVerified returns 'True' ...can I convert that value to 'Yes' by using some sort of function?
View 2 Replies
View Related
Jun 9, 2005
I have an anonymous PL/SQL block that I'd like to Convert into T-Sql and im completly stumped on 2 things:
What is the equvilent of a Cursor and how do I declare one?
How do I declare an anonymous block?
my code wrote:
Declare
-- Type Declarations
Type ct_UConstr_Cur is REF CURSOR;
v_Begin Integer := 0;
v_End Integer := 0;
v_PageSize Integer :=0;
c_Data ct_UConstr_Cur;
Begin
v_PageSize := :PageSize;
v_Begin := ( v_PageSize * :PageNumber) - 1;
v_End := v_Begin + v_PageSize;
Open c_Data For
Select * from (
Select A, B, C, ROWNUM as RN from Foo;
) where RN >= v_Begin AND RN < v_End;
:cur := c_Data;
END;
/
View 2 Replies
View Related
Sep 15, 1999
Does any one know of a tool SQL 7 has for doing this kind of conversion?
View 2 Replies
View Related
Jun 29, 2007
ok i am very very new at this, ive downloaded the SQL 2005 trial and i can not seem to figure this out. I have a .xls i want to make a active sql page out of. please please help me with this
the .xls is here http://www.mediafire.com/?5jtgzcxb232
feel free to email me @
bevanglynn@gmail.com
thanks
View 1 Replies
View Related
May 25, 2007
Hi there,
Here at my work(in Germany) i have a big problem:
Once a week there is a sqlscript, which should run and store data to a txt file.
There is a tablle in which imagedata is stored in RAW format(that one with small boxes, Qmarks and dots...).
Now i want to export it to the txtfile as HEX, so i can decode it by php further.
With the thumbnail, also stores there everything is fine, the SQL looks that way:
SELECt hex(thumbnail) FROM picTable where id_pic=54985
The Data is then displayed as HEX. But the standart picture is to big. When i use the statement:
SELECt hex(bigpic) FROM picTable where id_pic=54985
i got the error message:
An error occurred while running the query.
The data type, length, or value of argument 1 of HEX is invalid.
(SQL code = -171, SQL state = 42815)
After some research i found that the maximum lenght is 16 336 bytes for the HEX-operation. The picture is nearly 30 000 bytes... :shocked:
Have anyone an idea how to fix that?
I am not able here to accsess to the database direct...
I have been working for days on it.
View 4 Replies
View Related
May 22, 2007
Hi All,
I am in the process of changing the cursor based Proc with temp tables, I have one of the Procs which is beening used to get a value for the cursor, I am thinking if it is possible to change it to a function so that I can update the column at once.
[code]
CREATE PROCEDURE[dbo].[get_cre_tijd_id] (
@tijd_datum datetime,
@tijd_id int output
)
AS
DECLARE @datum_tekst VARCHAR(25)
DECALRE @datum_tijd DATETIME
SET @datum_tekst = CAST(@tijd_datum AS VARCHAR);
SET @datum_tijd = CONVERT(DATETIME, SUBTRING(@datum_tekst, 1, 12), 21 )
SET @tijd_id = (SELECT tijd_id FROM dim_tijd WHERE tijd_datum = @datum_tijd )
IF @tijd_id IS NULL
BEGIN
INSERT INTO dim_tijd (
tijd_datum
, jaar
, kwartaal
, maand
, dag
, periode
, week
, weekdag
)
VALUES ( @datum_tijd
, datepart(yy,@tijd_datum)
, datepart(q,@tijd_datum)
, datepart(m,@tijd_datum)
, datepart(d,@tijd_datum)
, ceiling(datepart(wk,@tijd_datum)/4.00)
,dbo.get_iso_week(@tijd_datum)
, datepart(dw,@tijd_datum)
)
SET @tijd_id = (SELECT tijd_id FROM dim_tijd WHERE tijd_datum = @datum_tijd)
END
Necessity is the mother of all inventions!
View 4 Replies
View Related
Sep 26, 2007
Hello all,
I am subtracting two datetimes (last(fields!FaultStart.value))-(first(fields!FaultStart.value)) this works fine and returns a value in a textbox 5.23:44:23. I need to convert that number to minutes I am very new to sql programming and do not know very many commands. I am using Microsoft sql server 2005 express edition along with sql server business intelligence development studio where I placed a textbox and entered the expression above. I have also tried to use datediff command
=datediff(second, (last(fields!FaultStart.value)),(first(fields!FaultStart.value)))
but the second is underlined and tooltips says WRONG NUMBER OF ARGUMENTS I€™ve tried
=datediff(€œsecond€?, (last(fields!FaultStart.value)),(first(fields!FaultStart.value)))
and
=datediff(€œ€™second€™€?, (last(fields!FaultStart.value)),(first(fields!FaultStart.value)))
also for second I€™ve tried seconds. Any help would be most appreciated
Thanks
Ed
View 3 Replies
View Related
Nov 8, 2007
I haven't seen a really good solution for this in amongst the threads about UTC. What I want to do is convert a date time to UTC, taking into account whether or not it is in DST, and be able to deploy this code to any server in the world without customizing the SQL code, and have it know how to convert, as long as a I feed it the local Time Zone.
I would think this would be easy because the OS knows at any given time what time zone has what UTC offset, and exactly at what time DST starts and ends. Right now I do this, but it is limited. I have a table that, for each site (there can be more than one site in different time zones) stores the UTC offset and whether or not the site observes DST. New York would have the "Observes_DST" set to 1, Phoenix would have it set to zero. The "Hours_To_UTC" value would be 5 for New York.
This code below assumes all sites are located in Canada or the US, as Canada and the US now use the second Sunday in March and first Sunday in November as the switch over times. (although this would work fine for countries like India and China that don't observe DST).
UPDATE a
SET Time_Arrived_UTC =
CASE
WHEN b.Observes_DST = 1 THEN
CASE
WHEN Month(Time_Arrived) IN (4,5,6,7,8,9,10) THEN
DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 3 AND Day(Time_Arrived)- DATEPART(dw,Time_Arrived) >= 7 AND
Day(Time_Arrived) <= 14 AND DATEPART(dw,Time_Arrived) <> 1
then DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 3 AND Day(Time_Arrived) > 14
then DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 3 AND Day(Time_Arrived) >= 8 AND Day(Time_Arrived) <= 14 AND
DATEPART(dw,Time_Arrived) = 1 AND DATEPART(hh,Time_Arrived) >= 2
THEN DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 11 AND Day(Time_Arrived) <= 7 AND DATEPART(dw,Time_Arrived) = 1 AND
DATEPART(hh,Time_Arrived) < 2 then DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
WHEN Month(Time_Arrived) = 11 AND Day(Time_Arrived)- DATEPART(dw,Time_Arrived) < 0 then
DATEADD(hh,b.Hours_From_UTC - 1,Time_Arrived)
ELSE DATEADD(hh,b.Hours_From_UTC,Time_Arrived)
END
ELSE DATEADD(hh,b.Hours_From_UTC,Time_Arrived)
END FROM
Facts_Table a INNER JOIN Site_Info_Lookup_Table b
ON a.Site_Name= b.Site_Name
This works, (and is much more efficient than using a UTC lookup table) and I could probably go about hard coding various other start and end DST datetimes for other time zone DST (Australia and Europe, for example), but that wouldn't be dynamic in case one country makes a change in policy that changes when DST starts and stops, like the US just did.
SQL Server only provides current time UTC conversion--I would think it should have a function like this:
ConvertToUTC(datetimevalue,timezone)
Oracle has a function like that, but it is useless because it doesn't take into account DST, it would for instance just add 5 hours to EST for every date you entered (now that's helpuful!). It is baffling that this function doesn't exist.
I am using Integration Services so I could probably build a script task that would query the OS for DST start and stop times given a particular time zone (if available), but I'm not much of a coder--would be nice to have an easy way to do it in Transact-SQL.
Thanks,
Kayda
View 5 Replies
View Related
Oct 1, 2006
Hi All,
I'm needing to take a value inputted by a user via html form and convert it to a hex value upon inserting into SQL2000 db. I only need to store the 8 chars after "0x". Is there any T-SQL that can pull this off? CAST or CONVERT? Sorry if this is a silly question and hope I supplied enough info...
Thx,
Mike
View 1 Replies
View Related
Dec 7, 2006
Hi I am converting data from old DB to NEW DBIn the OLD table fields like "PhoneNumber" the data enterd are [ 657 985-986, (03)-987-543, 675(89)00, ect]Is their any function in sql where I can get rid of all those spaces and () and - between the numbers as my new field is only numbers and with out spaceOtherwise I have to clean them up manually as I have 1000000 records
cheers
View 1 Replies
View Related
Dec 8, 2006
I have a stored procedure which I user to retur an Email-address from aspnet_Membership (DB-table).
Here is the code:
ALTER PROCEDURE dbo.StoredProcedure2 @user nvarchar(256) AS DECLARE @id uniqueidentifier SET @id = '' SELECT @id = UserId from aspnet_Users WHERE UserName = @user SELECT Email From aspnet_Membership WHERE UserId = @id
I use StoredProcedure2 in this way:
Dim cmd As SqlCommand = New SqlCommand("StoredProcedure2", MyConnection) cmd.CommandType = CommandType.StoredProcedure
'send in UserName as @User to StoredProcedure2 cmd.Parameters.Add("@user", SqlDbType.NVarChar).Value = User.Identity.Name.ToString() 'Return EmailAddresse returnValue = cmd.ExecuteScalar()
Message I get is:
"Conversion failed when converting from a character string to uniqueidentifier"
Please help...
View 2 Replies
View Related
Mar 27, 2007
Hi,
I am developing a project that using the one of the starter kits which use the MS SQL EXPRESS database.The project is almost ready to be launch.
few questions:
I am looking for a good host with good support reasonable paid.
What is my options if I would like to convert from the current database, to other databases like MySql, MS SQL Server or any? which tools can help with this convertions?
thats all, thanks.
View 2 Replies
View Related
Feb 25, 2008
I have an old table (table1) and a new table (table2). I need to move some of the data from table1 to table2.
For my example, table1 contains 1 field that is a DateTime, we’ll call it table1_Date.
table2 also contains 1 field that is a SmallDateTime, we’ll call it table2_Date.
I want to do something like this:
Insert into table2
table2_Date
Select
table1_Date
From table1
Where …..
I am getting the following error:
The conversion from datetime data type to smalldatetime data type resulted in a smalldatetime overflow error.
How can I go about converting this on the insert?
View 9 Replies
View Related
May 27, 2008
hi,
can any one tell me how to convert my access data to sql server data. using sql server express edition
View 2 Replies
View Related
Mar 26, 2004
hi..
may i know how to convert from mysql to microsoft sql server ??
is it very troublesome ??
coz its quite a big project..
i need to convert frm mysql to sql..
is there any example or reference?
thanks
View 7 Replies
View Related
Oct 14, 2004
Hello Everyone and thanks for your help in advance. I have an application that inserts a variety of values into a SQL Server database. Among the columns are three DateTime values. I have code working properly on my test server, but when I port the identical code to my production database, I get the following error:
Arithmetic overflow error converting expression to data type datetime. The statement has been terminated
When I remove any type of insert involving date, the application works. I have tried the date in various formats, for instance "09/12/2001" and "20010912", but still get the same error. Obviously, there must be differences in the SQL Servers, but I have never run into this problem before and the current server is running many applications involving dates. I haven't got a clue as to how to solve this problem. Any help is greatly appreciated. Thanks.
View 1 Replies
View Related
Mar 2, 2005
I have a control with checkboxes. The checkbox.checked property returns a boolean value. If I want to insert a record into a table that has a corresponding column of type bit, how do I do it?
I triedCType(myChkBox.checked,String), which returns the strings "True" or "False". But, I get the errorThe name 'True' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.I then tried "CAST(" & CType(myChkBox.checked,String) & ",bit)", but got the same error.
I can write a function that will return a 1 or a 0 but that seems ludicrous. Surely there must be a more elegant way to use the result of a checkbox in an SQL statement.
Thanks
Martin
View 4 Replies
View Related
Jun 2, 2005
I have a tbale with maybe 30 columns and I'm selecting all where a
record number matches a parameter I've passed. That works fine,
however is there any way to do some conversions to fields when
selecting without having to list out each column? For instance
this is what it looks like now:
SELECT *
FROM Losses
WHERE @AppRecord = AppRecord
ORDER BY Record ASC
But I want to convert say one column, is there a way to keep similar syntax instead of listing out each column?
SELECT *, CONVERT(varchar(15), [Losses]) as [Losses]
FROM Losses
WHERE @AppRecord = AppRecord
ORDER BY Record ASC
And the column I'm converting is of type 'money'. I'm converting
it to get rid of the extra zeroes at the end. If you know a
better way to do it I'd be interested in knowing.
View 4 Replies
View Related
Oct 13, 2005
I recently got a new job at a new company. My previous experience
had all been with Oracle DB's but the new place uses Sql Server
2k. I have a few general questions about how to do stuff in
SqlServer...
1) how do I create a sequence and a trigger?
2) I know SqlServer probably doesnt have anything like Packages, so are
procedures local to schemas? and if so, are schema's nestable in any
way?
3) Can anyone reccomend a good book on T-SQL?
View 5 Replies
View Related
Oct 17, 2005
I have been given a Product table whoes all column types are varchar(8000)
One of the column is Price and other is DecimalPosition. Price column includes price without any decimal place and the data in DecimlaPosition column determins where the decimal should be placed.
So for instance, if the Price column includes '1000' and DecimalPosision includes '2' >> then it means that the actual price for this product is '10.00' and NOT '1000'. Similarly, if the DecimalPosision includes '3' >> then it means that the actual price for this product is '1.000' and NOT '1000'My question is that when I am getting the price for a product from this table, how can I get the price in the correct format, e..g like '10.00' and not '1000'Should I use SQL statements to convert 1000 into 10.00 or should I use some sort of programming logic to convert 1000 into 10.00.kind regards
View 2 Replies
View Related
Apr 10, 2000
I want to upgrade my 6.5 SQL Server to version 7, but it looks like I don't have enough disk space.
I installed version 7.0 and launched the SQL Server Upgrade Wizard in hopes of converting my databases (objects and data)
from 6.5 to 7.0. Instead, the wizard wants to make *copies* of my databases in the 7.0 instance. These databases are large
and I don't have enough room for a second copy of each database. Is there no way to *convert* the existing .dat files from 6.5
to 7.0 format? I want to avoid doubling the disk capacity of my server.
View 1 Replies
View Related
Jan 18, 2000
Hello!
I have a column tData with char(10)datatype - dd/mm/yyyy.
I try to convert them to datetime, here is statement:
select convert (datetime(103),tData)
from Test1
As result I have got error message:
conversion of a char data type to a datetime data type resulted in
an out-of-range datetime value.
What I'm doing wrong?
Thanks a lot.
View 1 Replies
View Related
Jun 9, 2000
Two datatype problems: (1) Datetime conversion (2) Foreign Currency format.
The first problem is that I am trying to convert source data from varchar to datetime. The source data is in CSV format and is displayed as follows - '1111999052349' to represent 1-Nov-1999 05:23:49. Have converted to a numeric value and then tried to convert to datetime but this just returns the following message 'Server: Msg 8115, Level 16, State 2, Line 3
Arithmetic overflow error converting expression to data type datetime.' However you can convert to a timestamp but the value returned is not meaningful (e.g. 0x0E0000013DFA4EE8).
Problem 2 concerns the French currency. The source data is in CSV format and is displayed as follows - '00000001,9700' to represent Fr1.97. Need to convert this to a numeric field or alternatively get SQL 7 to recognise it as a money field.
Any suggestions would be musch appreciated.
Many Thanks.
View 2 Replies
View Related
Dec 20, 2001
I need to convert a text field (which contains only numbers) into an int field. What would be the easiest way to do so. SQL 6.5. There are about 100, 000 rows in the db.
Thanks.
View 1 Replies
View Related