Passing A Timestamp Datatype Column To A Variable And Back
Aug 10, 2006
After several hours of trying, I trow the towel in the ring and come here to ask a question.
Source system uses a timestamp column in the transaction tables. which is equal to a non-nullable binary(8) datatype (sql 2000 bol).
What I want to do is get the timestamp at the start of the transfer and at the end of the transfer of data. and store these in a controltable
I try to do this in 2 sql execute tasks:
sqltask 1: "select @@DBTS AS SourceTimestamp" and map the resultset to a variable. Here come's the first problem what variable type to take ?
DBNULL works (meaning it doesn't give errors) (BTW: is there a way to put a variable as a watch when debugging sql tasks ?)
INT64 and UINT64 don't work error message that types for column and parameter are different
STRING works
Then I want to store this variable back in a table of a different data source
sqltask2: "insert into controltable values(getdate(), ?)" and make an input parameter that takes the previous timestamp ...
if I took DBNULL as a type for the variable there doesn't seem to be a single parameter type that works ???
if i take STRING as a type for the variable I have to modify the sql to do the explicit conversion from string to binary so I change CAST(? as binary). It doesn't return any error but the value stored in the table is 0x00000000000 and not the actual timestamp.
Any help on this one ? Why are the INT64/Bigint not working here, you can perfectly do a convert(bigint, timestampfield) in sql ?
How came the SQL datatypes, and the variable datatypes, parameter datatypes are so badly alligned to each other (and all seem to use different names) ?
tx for any help
Dirk
View 6 Replies
ADVERTISEMENT
May 26, 2004
--------------------------------------------------------------------------------
I would like to get information related to timestamp data type in SQL Server (WANT TO SET NULL IN TIMESTAMP COLUMN )I have Following case
try {
try {
stmt.execute("drop table timestampTable");
}
catch (SQLException ex1) {
}
stmt.execute(
"Create table timestampTable(c1 int Primary Key, c2 Timestamp)");
PreparedStatement pst = connection.prepareStatement(
"insert into timestampTable values(?,?)");
pst.setInt(1, 2);
pst.setNull(2, Types.TIMESTAMP);
pst.execute();
}
catch (SQLException ex) {
ex.printStackTrace();
}
TRACE IS GIVEN BELOW
====================
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Disallowed implicit conversion from data type datetime to data type timestamp, table 'ClientDB.dbo.timestampTable', column 'c2'. Use the CONVERT function to run this query.
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.proces sErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.proces sReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.pro cessReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.proces sReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplStatemen t.getNextResultType(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonTransi tionToState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.postImplExec ute(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.post ImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecut e(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeInter nal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.exec ute(Unknown Source)
at JDBC.TestSQLServer.testTIMETAMPDataTypes(TestSQLSe rver.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.daffodilwoods.tools.testworker.TestRunner.runM ethod(TestRunner.java:159)
at com.daffodilwoods.tools.testworker.TestRunner.runI nSequence(TestRunner.java:83)
at com.daffodilwoods.tools.testworker.TestRunner.runT estCase(TestRunner.java:4
PLEASE REPLY ME AS SOON AS POSSIBLE
THANKS
SUBE SINGH
View 1 Replies
View Related
Aug 24, 2005
Is it possible to use a table's fieldname as an SQL variable?
i.e. can the below be made to somehow work:
Code:
SELECT Firstname, Surname, myVariable
FROM ContactDetails
WHERE myVariable = [user input];
- or simply -
Code:
SELECT Firstname, Surname, [user input]
FROM ContactDetails;
---
The "user input" being any other chosen column/fieldname from the ContactDetails table (e.g. Street, City, Postcode, etc.).
i'm using Access and ASP - in case that makes a difference.
any help would be greatly appreciated.
View 1 Replies
View Related
May 11, 2007
I am trying to pass a variable set by a Row count transformation to a derived column transformation. There are actually three separate Row Count transformations storing to different variables. In the derived column trans. the expression i am using is @[User::ClientCount] and the variable type is Int32 and I am passing it to an I4 database column. After the derived column trans. all rows just come out with 0s in the row count columns. Does anyone know why this would be? Please let me know if you need more information.
View 3 Replies
View Related
Mar 13, 2015
I am building a generic SSIS where it takes a text source file and converts to a destination source file . However in the process I want to set the row delimiter and the column delimiter dynamically through the package variable. So that I can use it for any file transfer.
I saw the option for row delimiter in the file connection string property but did not see any column delimiter option.
View 3 Replies
View Related
Apr 24, 2008
Good afternoon,
I have an issue with an ssis variable datatype.
The scenario is as follows:
I have a stored procedure:
PROCEDURE [dbo].[sp_newTransaction]
@sourceSystem varchar(50),
@txOut NUMERIC(18,0) OUTPUT
AS
insert into scn_transaction (sourceSystemName) values(@sourceSystem);
SELECT @txOut = @@identity
Whose purpose is to perform an insert into a table and return me the identity value of the inserted record, which I'll then use throughout the rest of my package. The identity column in the inserted table is numeric(18,0).
I execute the stored proc with the following sql with an OLE DB connection manager:
exec sp_newTransaction ?, ?
The first parameter is a string variable from earlier in the package, and the second is the output parameter. I have the following parameter mappings to the execute sql task:
User:ystxId output numeric 1 -1
User:ourceSys input varchar 0 -1
The proc is correctly called, and the row insesrted, however I get a type conversion error when SSIS attempts to map the return parameter to my package variable... I've tried all sorts of combonations, and can't seem to get it to execute.
At one point I wasn't returning a numeric, but rather an int from the stored proc, and all was well until I went to use the variable in a derived column later in the package, and the type was converted quite incorrectly (a 1 was 77799789080 or some such), indicating a type conversion error likely related to the encoding of the number.
I'd like to keep the datatypes as numeric and make ssis use those - any pointers are greatly appreciated as to what type my package variable should be to allow proper assignment of a sql server numeric type to it.
Thanks much,
B
View 6 Replies
View Related
Mar 28, 2006
Hello, I'm attempting to use the Sql Timestamp (Rowversion in 2005) datatype for optimistic concurrency for my SqlDataSource because the table I'm updating has a few columns that can be null which breaks the optimistic concurrency code generated by visual studio. However, the Type's available for SqlDataSource parameters do not include "Timestamp" and everything else I've tried throws exceptions. SO, is there anyway to use the timestamp/rowversion datatype with a SqlDataSource? Many thanks for your help, I have been googling this for literally hours. Thanks again.Drew
View 5 Replies
View Related
Jan 16, 2004
Hi all,
I have moved a mysql table to SQL Server and the table had an int datatype storing the value of the Unix timestamp. I want to convert this datatype into a DATETIME type in SQL Server.
Any ideas how I could do it?
Thanks in advance.
View 8 Replies
View Related
Jul 14, 2014
What sql data type would fit these value? This is timestamp field in the ERP.
2013-05-24-20.03.46.843480
View 3 Replies
View Related
Jun 23, 2015
I have column which has timestamp datatype.in this column inserting date in encrypt format.
I want insert date format into that column.If it is not possible to insert date format while fetching (through select statement) want to decrypt format ( I mean date format).
View 6 Replies
View Related
May 28, 2008
Hi,
i wanted to read some datasets from a table with the ROWVERSION. Then i wanted to save these records with the ROWVERION- Column in a temp table. Now it seems i cant explicitely write data in a ROWVERSION Column. As i understand its only possible to write a default value in such columns. Only SQL Server itself can write into ROWVERSION columns.
Am i right with this meaning?
Thx in advance...
Greets Kamei
View 4 Replies
View Related
Jul 16, 2007
I created a SSIS package and creating a derived column named: Date...set datatype as DT_DBDATE....I do not want the timestamp on date...then I want to load this Date into a SQL server database table, with datatype of datetime, but it will load here with the timestamp which I do not want. Any ideas? I did change datatype of the SQL Server Destination datatype to DT_DBDATE but it will change it back to DT_DBTimestamp. thx
View 1 Replies
View Related
Mar 6, 2008
I have a SQL Task that updates running totals on a record inserted using a Data Flow Task. The package runs without error, but the actual row does not calculate the running totals. I suspect that the inserted record is not committed until the package completes and the SQL Task is seeing the previous record as the current. Here is the code in the SQL Task:
DECLARE @DV INT;
SET @DV = (SELECT MAX(DateValue) FROM tblTG);
DECLARE @PV INT;
SET @PV = @DV - 1;
I've not been successful in passing a SSIS global variable to a declared parameter, but is it possible to do this:
DECLARE @DV INT;
SET @DV = ?;
DECLARE @PV INT;
SET @PV = @DV - 1;
I have almost 50 references to these parameters in the query so a substitution would be helpful.
Dan
View 4 Replies
View Related
Oct 10, 2000
I am trying to pass a datename in to a database backup. The date is to be retrieved from the 'monthname' column which is stored in the 'tblbill' table. I have included my ridiculous bit of code below (which funnily enough does not work!!) just so that you can see what I am trying to do. Can anyone help?
DECLARE @name varchar(10)
backup database Bill to Disk ='c:@name.dat' with init
@name =select distinct monthname from tblbill where monthname is not null
cheers,
Dennis
View 2 Replies
View Related
Dec 19, 2007
Hi,
I'm not sure if this question should be in this thread but anyway...
I have a form (Mricosoft Access front end) in which the user enter a Pending Date in one of the fields. The date is populated into my backend (SQL Server) withouht problems.
Whenever the issue which had the pending date in the field is resolved I'd like to delete this date from this field and also from the back end. At the moment I'm not being able to pass the "value" Null to my back end (probably because it's a datetime type). I've searched the net throughout and I couldn't find a way around it. Only found solution to when the data is not date but numbers/letters, etc... Any ideas on how can I sort this out?
Many thanks
Emanuel
View 3 Replies
View Related
Apr 1, 2003
While debugging a stored proc in Sql Query Analyser i have to pass value to stored proc param which is of datatype datetime
i passed it as '03/31/2003'
it's giving error "[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification"
if i make it null it's working fine
pls suggest which date format value supposed to supply for datetime param to run debugging successfully
View 7 Replies
View Related
Jul 10, 2007
For starters, please feel free to move this if it is in the wrong forum.
The issue I have is this. I have been asked to delete all information from a table that was inserted before May 12 this year. The issue is that when the DB was created, whoever designedd it neglected to add a timestamp column for the user data table (the one I need to purge). Does SQL, by default, happen to store insert times? Would it be something that might hide ina log file somewhere?
View 4 Replies
View Related
Jun 4, 2007
Hi,
I have created a job in SQL Server 2005 in which one of the step executes a .NET console application which is created in .NET to update some status to database before the next step. i need some help in sending some status back to sql job when i come accross any problem in the console application for ex when there is a exception i need to send some status to the job, so the job gets failed permanently. i tried few other methods of updating some temporary status database with this error information and have another intermediate step in the job to check for the status... it worked but i dont like doing it. please let me know if there is any other method to do this.
Thanks in advance
Hariharan
View 5 Replies
View Related
Feb 15, 2008
Hi All!
I have a parent package that contains two children... The second child depends on the succes of the first child.
THe first child generates a variable value and stores it in an Environment variable ( Visibility - All ) ...After the first succeeds, the second will start executing and will pick up the variable value from environment variable( through package configuration setting )...
Unfortunately, this doesn't work...As the second child picks the stale value of the environment variables...Essentially it assigns variable value not after the first child is finished, but right at the beginning of parent execution...
I tried to execute coth children as Out Of Proc as well as In Proc...The same
Would anybody have an idea how to resolve this problem?
Thanks in advance for any help!
Vladimir
View 5 Replies
View Related
Jul 21, 2006
The DATEDIFF(s, time1, time2) function output is of the 'datetime' datatype.
How can I alter the 'datetime' to 'int' (or 'bigint') datatype to make it compatible with other variables in my calculations?
View 7 Replies
View Related
Aug 29, 2005
I have image type col.I'm trying to do the following,DECLARE @Data varbinary(16)SET @Data = (select imageCol from Table1 where id=3)As image datatype returns varbinary value, so I want to store image col value to a varbinary variable(or any other type variable, eg., varchar). But getting following error,========================================Server: Msg 279, Level 16, State 3, Line 2The text, ntext, and image data types are invalid in this subquery or aggregate expression.========================================Is there anyway to store image datatype value to a variable?Cheers.
View 2 Replies
View Related
Mar 12, 2003
I've created a stored procedure that converts an input string in richtext format (input as type TEXT) to plain text. I would like to be able to return this newly converted string, but I need to have some way of storing it in a local variable. My problem is that since I can't use the TEXT datatype as a local variable, I have no way of storing the large amounts of text I converted within the procedure. The VARCHAR(8000) just isn't large enough for my purposes. Anyone have any suggestions on how to go about doing this?
View 2 Replies
View Related
May 30, 2007
hi everyone,
How do i declare a global variable in my package which takes a numeric value like User::VAR1 = 200402 and later on work on it
Later in the properties of the Dataflow i want to have this expression..
"select * from " + "TAB1" + " where Date=" + @[User::VAR1]
Here i want to subtract 190000 from @[User::VAR1] to get it in to myformat i.e the DATE format in the table
I can only see String datatype and othe datatypes wont allow me to to do any kind of manipulation in the expression:
and to be more specific what are
Int16
Int32
Int64
Double
I tried to use all of the above but the expression doesnt allow me as it says:
TITLE: Microsoft Visual Studio
------------------------------
Nonfatal errors occurred while saving the package:
Error at Extract: The data types "DT_WSTR" and "DT_I8" are incompatible for binary operator "+". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.
Any help would be appreciated..
thanks,
ravi
Nothing much that i can do..!!
View 2 Replies
View Related
May 30, 2007
hi everyone,
How do i declare a global variable in my package which takes a numeric value like User::VAR1 = 200402 and later on work on it
Later in the properties of the Dataflow i want to have this expression..
"select * from " + "TAB1" + " where Date=" + @[User::VAR1]
Here i want to subtract 190000 from @[User::VAR1] to get it in to myformat i.e the DATE format in the table
I can only see String datatype and othe datatypes wont allow me to to do any kind of manipulation in the expression:
and to be more specific what are
Int16
Int32
Int64
Double
I tried to use all of the above but the expression doesnt allow me as once i use any of the above it says :
TITLE: Microsoft Visual Studio
------------------------------
Nonfatal errors occurred while saving the package:
Error at Extract: The data types "DT_WSTR" and "DT_I8" are incompatible for binary operator "+". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.
Any help would be appreciated..
thanks,
ravi
View 8 Replies
View Related
Sep 29, 2006
I have a parent package (i.e. P) and a child package (C). I was able to easily pass a variable value from P to C. And C did computations and get a result (i.e. integer) and stored this integer to a variable (x).
Now I want the value of "x" to be passed back to P and store in P's variable (say Px). Anyone knows how to ?
Thanks
Steve
View 12 Replies
View Related
Aug 9, 2007
Hi,
This is pretty simple but I am doing somethin really stupid somewhere, I am trying to pass a value to a variable declared in a package using some SQL code, I declared a variable "var1" and assigned the scope to the package , then I dropped a execute SQL task within the package and wrote a simple sql code that would get the maximum id from a table, "select max(id) from table" , now I want to assign the variable this max value.so in the parameter mapping tab I select the variable give it a parameter name of 0 and size of -1 along with direction of "output". everythin looks simple but when I try to use this variable value in my next execute sql task it behaves weirdly, I am trying to update anothet table using this variable value, so I add another task and put this code in there " update table2 set id = ? " , and on the parameter mapping tab I set the direction as input, however when I look at the column it updated th column with a weird number , xomethin like "230072408" which doesnt mean anything. I know that tha max value of ID is 10.
Please help.
Thanks
View 13 Replies
View Related
Mar 13, 2004
Why can varchar datatype variable only 4000 byte?
For example:
in a storedprocedure
declare @aa varchar(8000)
......
while
select @aa=@aa+@otherinfo
end
when the length is more than 4000 ,the data in the behind will be lost
View 1 Replies
View Related
Aug 22, 2007
Hello guys!
I am looking for the best DataType that makes it possible to store strings of variable length (from 15 to 300 caracters, rarely longer).
Thanks a lot for any help !
Regards,
Fabianus
my favorit hoster is ASPnix : www.aspnix.com !
View 3 Replies
View Related
Mar 11, 2002
Hi!
What correct statement should be to convert timestamp column to datetime.
I wrote:
select convert(datetime, update_date)
from table_name
and it doesn't work properly.
Thank you,
Elena
View 1 Replies
View Related
Mar 27, 2008
I have a table with a [Timestamp] field which is a datetime data type. What I need to do is add one hour to the timestamp.
Each entry in the [Timestamp] field looks like this: 2008-03-09 16:44:06.313
What is the best way to do this?
(Should I be using UPDATE [Tablename] or Alter Table [Tablename])
View 4 Replies
View Related
May 18, 2007
Can't seem to pass a variable to the sql statement. I'd appreciate any help. I'm trying to pass pColName to CommandText = "ALTER TABLE tb_roomInfo ADD @rColName varchar(50);";Doesn't seem to work though. CODE: [WebMethod] public string addCol(string pColName) { SqlConnection cnn = new SqlConnection(connString); try { cnn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cnn; cmd.CommandText = "ALTER TABLE tb_roomInfo ADD @rColName varchar(50);"; SqlParameter rColName = new SqlParameter("@rColName", pColName); cmd.Parameters.Add(rColName); int i = cmd.ExecuteNonQuery(); cnn.Close(); return "Insert Successful"; } catch { return "Insert Unsuccessful"; } }
View 3 Replies
View Related
Jun 14, 2007
Hi All, Would somebody be able to help me from pulling my hair out!??I have a form with a radiobuttonlist. I would like to change my select statement depending on what radiobutton value is selected.E.g.SELECT * FROM table WHERE <<variable from radiobuttonlist>> LIKE 'Y'So,if radiobutton value selected = 1, it will select * from column A in the dbif radiobutton value select = 2, it will select from column B in the dband so on... Am i attempting to do the impossible?Thanks All,
View 4 Replies
View Related
Jan 18, 2008
Hello,
I have a SP that recevies a date value for a users date of birth called "dob".
However when passing it into the class which contains the Stored procedure it gives an error.
Below is my code
please advice
Thanks
Ehi
1
2 command.Parameters.Add(new SqlParameter("@usernames", SqlDbType.Int, 0, "RegionID"));
3 command.Parameters.Add(new SqlParameter("@username", SqlDbType.VarChar, 20, "username"));
4 command.Parameters.Add(new SqlParameter("@First_Name", SqlDbType.VarChar, 50, "First_Name"));
5 command.Parameters.Add(new SqlParameter("@Last_Name", SqlDbType.VarChar, 50, "Last_Name"));
6 command.Parameters.Add(new SqlParameter("@dob", SqlDbType.Date, 50, "dob"));
7
8 command.Parameters[0].Value = 4;
9 command.Parameters[1].Value = "username";
10 command.Parameters[2].Value = "First_Name";
11 command.Parameters[3].Value = "Last_Name";
12 command.Parameters[4].Value = DateTime.Parse(dob.Text);
HERE IS THE ERROR MESSAGE
Compiler Error Message: CS0103: The name 'dob' does not exist in the current context
Source Error:
Line 40: command.Parameters[2].Value = "First_Name";
Line 41: command.Parameters[3].Value = "Last_Name";
Line 42: command.Parameters[4].Value = DateTime.Parse(dob.Text);
Line 43:
Line 44: int i = command.ExecuteNonQuery();
Source File: c:inetpubwwwrootcellulant1App_Codesignup_data-entry.cs Line: 42
View 7 Replies
View Related