January 19, 2009 at 5:32 am
i need to convert DateTime to BigInt through query in SQL
plz let me know
January 19, 2009 at 5:47 am
use CONVERT or CAST function
-Vikas Bindra
January 19, 2009 at 5:57 am
Thanks for ur reply
but i need to convert a column of table which has datetime type
please let me kno the Query
January 19, 2009 at 6:00 am
munishprathap (1/19/2009)
i need to convert DateTime to BigInt through query in SQLplz let me know
What does this column presently contain? Can you post a range of values?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 19, 2009 at 6:05 am
its a new table didnt hav any values in that column.
assume that column 1 has Id as bigint ,column 2 has Date as datetime
my aim is to alter the column 2 type as bigint and column 1 as identity column
January 19, 2009 at 6:12 am
Should have mentioned in the first post...
If there is no data in the table you can use ALTER TABLE...
-Vikas Bindra
January 19, 2009 at 6:18 am
munishprathap (1/19/2009)
its a new table didnt hav any values in that column.assume that column 1 has Id as bigint ,column 2 has Date as datetime
my aim is to alter the column 2 type as bigint and column 1 as identity column
This looks like a straightforward operation - can you post your current table structure?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 19, 2009 at 7:36 pm
This is absolutely the wrong thing to do. Dates should not be stored as integers.
What are the business rules stating that you should convert the column from a DATETIME datatype to BIGINT? In other words, why do they want to do this?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 19, 2009 at 9:49 pm
Thanks Jeff
according to my requirement i need to keep the one column type as bigint but unfortunately
i keep it as DateTime after long time i found that it was DateTime Type. so i need to write
a Script / Query which updates the Column field type as BigInt from DateTime and set the ID Column as
Identity with primary key.
My Table Script
CREATE TABLE [dbo].Number (
[ID] [BIGINT] NOT NULL,
[LastModifyBy] [DATETIME] NOT NULL)
January 20, 2009 at 2:54 am
So, for some time bigint values were inserted into datetime column?
And now you need to restore them as bigint?
Is it right?
_____________
Code for TallyGenerator
January 20, 2009 at 4:42 am
not lik tht,
values entered in these column was datetime only but in future i need to make entries
only as bigint
January 20, 2009 at 4:50 am
munishprathap (1/20/2009)
not lik tht,values entered in these column was datetime only but in future i need to make entries
only as bigint
How many rows are currently affected?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 20, 2009 at 4:55 am
we cant predict no. of rows affected assume tht tables have 10 rows
January 20, 2009 at 4:57 am
munishprathap (1/20/2009)
we cant predict no. of rows affected assume tht tables have 10 rows
How many rows do you have in the table right now?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 20, 2009 at 5:00 am
Ok thts great
its having 10 rows and one column have DateTime type with values.
Viewing 15 posts - 1 through 15 (of 32 total)
You must be logged in to reply to this topic. Login to reply