Bigint Type Primary Key
Jun 19, 2006
I'm using Sql Server 2000/7 for my projects.
How to handle the situation if a primary key (a field set as identity) of type bigint gives an overflow problem?
Is there any way to reuse identities if a primary key field is set as identity from the database settings? (we can do this if we donot set the primary key field as identity from the datbase and handle it from front end)
please help
View 1 Replies
ADVERTISEMENT
May 10, 2005
We are trying to work with our developers to upgrade to SQL 2000 from SQL 7 for a critical applicaion and all looks good in testing for the most part. The concern that our developers have is that in order for the application to work on the test SQL 2000 server they had to delete a core data type (bigint) for the application to work. It doesn't appear to have any negative affects and we know for sure that the application database does not need that data type at all.
Can someone verify that there are no requirements for SQL 2000 needing to have this data type? They are worried that something within SQL may rely on it and we would find out the hard way in production possibly.
View 3 Replies
View Related
Feb 25, 2008
I getting the above error can someone please help me solve it, here is the code:
public void InsertHost() { // TODO // - Call stored procedure to write to a log file writeToLog using (SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"])) { SqlCommand cmd = new SqlCommand("writeToLog", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@pAction", "action"); cmd.Parameters.AddWithValue("@pHostName", "Hostname"); cmd.Parameters.AddWithValue("@pUserNUm", "requestorID"); cn.Open(); cmd.ExecuteNonQuery(); } }
Here is the storedprocedure:
ALTER PROCEDURE dbo.writeToLog(@pAction varchar(10), @pUserNUm bigint, @pHostName varchar(25))AS INSERT INTO dbo.hostNameLog (action, requestorID, HostName)VALUES (@pAction, @pUserNUm, @pHostName)
Here is the table:
HostName - varchar, action - varchar, requestorID - bigint
I can't seem to find the error.
View 7 Replies
View Related
Aug 25, 2005
I have the following query which has been giving me headaches for days : SELECT SCCode [Service Catalog Code], FileName [File Name], FullName [Full Name], FileExtension [Extension], FileSize [Size], Author [Author], CONVERT(VARCHAR(50),CAST(LastModified AS SMALLDATETIME), 120) [Last Modified], CONVERT(VARCHAR(50),CAST(LastAccessed AS SMALLDATETIME), 120) [Last Accessed], TimesAccessed [Downloads], UploadedBy [Uploaded By], CONVERT(VARCHAR(50),CAST(UploadedAt AS SMALLDATETIME), 120) [Uploaded At] FROM #TempTable WHERE id > @firstitem AND id < @lastitem ORDER BY CASE WHEN @sortcolumn = 'Service Catalog Code' THEN SCCode WHEN @sortcolumn = 'File Name' THEN FileName WHEN @sortcolumn = 'Extension' THEN FileExtension WHEN @sortcolumn = 'Size' THEN FileSize WHEN @sortcolumn = 'Author' THEN Author WHEN @sortcolumn = 'Last Modified' THEN CONVERT(VARCHAR(50),CAST(LastModified AS SMALLDATETIME), 120) WHEN @sortcolumn = 'Last Accessed' THEN CONVERT(VARCHAR(50),CAST(LastAccessed AS SMALLDATETIME), 120) WHEN @sortcolumn = 'Downloads' THEN TimesAccessed WHEN @sortcolumn = 'Uploaded By' THEN UploadedBy WHEN @sortcolumn = 'Uploaded At' THEN CONVERT(VARCHAR(50),CAST(UploadedAt AS SMALLDATETIME), 120) END ASCWhen my @sortcolumn parameter is either FileSize (BIGINT) or TimesAccessed (BIGINT) then the query returns the data without any problem. However, if I use a different @sortcolumn value such as "Author" then I keep getting "Error converting data type varchar to bigint."A solution that seems to work is to drop CASE and use lots of IF statements instead. I don't prefer to do this because it requires me to repeat the same select statement for each and every possible @sortcolumn value!Does anyone know how to solve this? Help!
View 2 Replies
View Related
Oct 18, 2013
i have this data:
BookedIDBooked_Date
1141996362013-01-09 14:55:21.740
would like to get the output into txt format with delimited in between columns.
i tried this but getting this error: Error converting data type varchar to bigint.
select BookedID+'|'+Booked_Date from tableA
View 5 Replies
View Related
Apr 17, 2015
This is a common error for SQL Server, but I got it in a uncommon way.I have a table called - tblIDNumber where there are two columns - IDN_Number [NVarchar(200)] and Temp [BigInt]
If I run,
SELECT Â *
FROM Â Â dbo.tblIDNumber
WHERE Â IDN_IDNumberTypeStaticValue = 33
    AND IDN_Removed = 0
    AND CAST(IDN_Number AS BIGINT) = 1
SQL Server give me the error:
Msg 8114, Level 16, State 5, Line 1
Error converting data type nvarchar to bigint.
I first thought IDN_Number in type 33 has characters, but it doesn't, becasue the below query works!!!
UPDATE dbo.tblIDNumber
SET Temp = CAST(IDN_Number AS BIGINT)
WHERE Â IDN_IDNumberTypeStaticValue = 33
    AND IDN_Removed = 0
To workaround, I ran the query,
UPDATE dbo.tblIDNumber
SET IDN_Number = '123'
WHERE Â IDN_IDNumberTypeStaticValue = 33
    AND IDN_Removed = 0
and then I ran the first query, and SQL Server does NOT give me the same error -Â Msg 8114, Level 16, State 5, Line 1 Error converting data type nvarchar to bigint.
Second query approved there is nothing wrong from converting the value in IDN_Number to a BigInt, but the third query gave the hint that data might be the cause?????
finally, I found the root cause to be an index that the first query uses :
CREATE NONCLUSTERED INDEX [IX_tblIDNumber_Covering] ON [dbo].[tblIDNumber]
(
[IDN_Removed] ASC,
[IDNumberCode] ASC
)
INCLUDE ( [IDN_Number],
[IDN_Reference]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 85) ON [PRIMARY]
GO
If I remove the index, the first query works without the error.
View 10 Replies
View Related
Oct 5, 2007
I have designed a SP where i need to update all the records for a table where ErrorId is not equal to the ones provided.In this stored procedure i am parsing and all the errorids delimited by ',' into a varchar variable which i would be using for updating the table.On the second last line i get the error mentioned in the subject line.any help would be appreciated.
ALTER PROCEDURE [dbo].[sp_ParseAndUpdateDetails]
@NozzleID int,
@ParserString varchar(MAX)
AS
BEGIN
DECLARE @NextPos int
DECLARE @LoopCond tinyint
DECLARE @PreviousPos int
DECLARE @FlgFirst bit
DECLARE @QueryCondition varchar(MAX)
SET @LoopCond=1
SET @NextPos =0
SET @FlgFirst=0
SET @QueryCondition=''
WHILE (@LoopCond=1)
BEGIN
--Retrieving the Position of the delimiter
SET @NextPos =@NextPos + 1
SET @NextPos = CHARINDEX(',',@ParserString, @NextPos)
--Retreiving the last substring
IF(@NextPos=0)
BEGIN
PRINT SUBSTRING(@ParserString,@PreviousPos + 1,(LEN(@ParserString)+1)- @PreviousPos)
SET @QueryCondition= @QueryCondition + ' AND ErrorId <> ' + CAST(SUBSTRING(@ParserString,@PreviousPos + 1,(LEN(@ParserString)+1)- @PreviousPos) AS bigint)
SET @PreviousPos = @NextPos
BREAK
END
--Retrieving the individual substrings
If @FlgFirst=0
--Retreiving the first substring
BEGIN
SET @FlgFirst=1
PRINT SUBSTRING(@ParserString,1, @NextPos-1)
SET @QueryCondition= @QueryCondition + CAST(SUBSTRING(@ParserString,1, @NextPos-1) AS bigint)
SET @PreviousPos = @NextPos
END
ELSE
--Retreiving the internmediate substrings
BEGIN
PRINT SUBSTRING(@ParserString,@PreviousPos + 1,(@NextPos-1)-@PreviousPos)
SET @QueryCondition= @QueryCondition + ' AND ErrorId <> ' + CAST(SUBSTRING(@ParserString,@PreviousPos + 1,(@NextPos-1)-@PreviousPos) AS bigint)
SET @PreviousPos = @NextPos
END
END
print 'ErrorId <>' + @QueryCondition
UPDATE [ESMS2_DBMS].[dbo].[ErrorDetails]
SET ErrorRectifyDateTime=GETDATE()
WHERE (NozzleId = @NozzleId) AND (ErrorRectifyDateTime IS NULL) AND (ErrorId <> @QueryCondition)
END
View 8 Replies
View Related
Jan 9, 2007
I am attempting to setup a replication from SQL Server 2005 that will be read by SQL Server Compact Edition (beta). I'm having trouble getting the Publication Wizard to create the Publication. Sample table definition that I'm replicating:
USE dbPSMAssist_Development;
CREATE TABLE corporations (
id NUMERIC(19,0) IDENTITY(1964,1) NOT NULL PRIMARY KEY,
idWas NUMERIC(19,0) DEFAULT 0,
logIsActive BIT DEFAULT 1,
vchNmCorp VARCHAR(75) NOT NULL,
vchStrtAddr1 VARCHAR(60) NOT NULL,
vchNmCity VARCHAR(50) NOT NULL,
vchNmState VARCHAR(2) NOT NULL,
vchPostalCode VARCHAR(10) NOT NULL,
vchPhnPrimary VARCHAR(16) NOT NULL,
);
CREATE INDEX ix_corporations_nm ON corporations(vchNmCorp, id);
GO
When the wizard gets to the step where it is creating the publication, I get the following error message:
Arithmetic overflow error converting expression to data type bigint. Changed database context to 'dbPSMAssist_Development'. (Microsoft SQL Server, Error: 8115).
I can find no information on what this error is or why I am receiving the error. Any ideas on how to fix would be appreciated.
Thanks in advance ...
David L. Collison
Any day above ground is a good day.
View 3 Replies
View Related
Nov 30, 2007
The strange in this problem is that i got this problem suddenly and before all was running without any error.
The script that cause the error is in the trigger for insertion on a table, there is somewhere where i convert from varchar to bigint, but all seems fine to me i printed the varchar variable and the conversion looks valid, also i included several print statement in the script for debugging purposes and i feel everything is right and there shouldn't be any error.
I don't think anything changed in my db, so i wonder where this problem is comming from ?
this is the code:
Code Block
-- Private Sending start
declare @tmpmsg nvarchar(200)
set @tmpmsg = ltrim(rtrim(@message)) -- Remove leading and trailing blanks
if (left(@tmpmsg,4))='خاص' and len(@tmpmsg)>6
begin
declare @msg_error nvarchar(70)
declare @msg_error1 nvarchar(70)
declare @msg_error2 nvarchar(70)
declare @msg_error3 nvarchar(70)
declare @sender_id bigint
set @msg_error1 = 'الرجاء إرسال كلمة خاص متبوعة برقم ملÙ? الشخص المطلوب ثم الرسالة الشخصية'
set @msg_error2 = 'الرجاء تسجيل ملÙ?Ùƒ قبل إستخدام خدمة الرسائل الخاصة'
set @msg_error3 = 'إن ملÙ? الشخص المطلوب غير موجود'
-- The message should not go to chat filtration
update received_in set sent = 3 where reqid = @id
-- if the sender profile doesn't exist, send him a message indicating that.
SELECT @sender_id = profile_id FROM profiles where msisdn=@msisdn
if @sender_id is not null
begin
set @tmpmsg = ltrim(right(@tmpmsg, len(@tmpmsg)-3))
-- Now the message looks like '12345 this is a test message'
declare @profileid bigint
declare @strprofileid nvarchar(50)
declare @posSpace int
set @posSpace = charindex(' ', @tmpmsg)
if @posSpace = 0 -- Not found (the message format is like this 'pri 3432434 ' or 'pri dfsdffsd '
begin
set @msg_error = @msg_error1
-- Insert the message into the filtration screen to be fixed by a filtrator, the recipient_id will be set to 0
insert into mobile_chat (sender_id, recipient_id, message, datein, timein)
Values (@sender_id, 0, @tmpmsg, @thedate, @thetime)
end
else
begin
set @strprofileid = left(@tmpmsg, @posSpace-1)
-- first char separating profileid and util message
if isnumeric(@strprofileid) = 1
begin
set @profileid = @strprofileid
declare @utilmsg nvarchar(200)
set @utilmsg = ltrim(right(@tmpmsg, len(@tmpmsg)-@posSpace))
-- Right message format
print 'Profile id=' + ltrim(str(@profileid))
print 'Message=' + @utilmsg
declare @recmsisdn varchar(16)
select @recmsisdn = msisdn From profiles where profile_id=@profileid
-- if the receiver profile doens't exist, send him a message indicating that
if @recmsisdn is not null
begin
-- All fine: msg format, sender and receiver
if left(@recmsisdn,3)='000'
Insert into Inbox (sender_id, recipient_id, message, datein, timein)
Values (@sender_id, @profileid, @utilmsg, @thedate, @thetime)
else
insert into mobile_chat (sender_id, recipient_id, message, datein, timein)
Values (@sender_id, @profileid, @utilmsg, @thedate, @thetime)
end
else
begin
-- Insert the message into the filtration screen to be fixed by a filtrator, the recipient_id will be set to 0
insert into mobile_chat (sender_id, recipient_id, message, datein, timein)
Values (@sender_id, 0, @tmpmsg, @thedate, @thetime)
set @msg_error = @msg_error3
end
end
else
begin
set @msg_error = @msg_error1
end
end
end
else
-- The sender profile is not registered with us
set @msg_error = @msg_error2
if @msg_error is not null
begin
print @msg_error
if left(@msisdn, 3) = '966' -- We can only send replies to KSA mobiles
INSERT INTO cgi_sms_services.dbo.cgi_sms_in(msisdn, sms_code, message, reqport, smstype)
VALUES (@msisdn, '1000000002', @msg_error, 86367, 'wcsms')
end
end -- Private Sending End
View 3 Replies
View Related
Dec 11, 2006
i have a employee table with various columns....
here i have emp_code as my primary key
now my concern is which data type is to be associated with the primary key(emp_code)
emp_code int not null,
OR
emp_code varchar not null,
wht i understand is to go for the simpler one....i.e. int, since it would be easy to deal with int data
now my basic question here is while creating tables which data type is to be assigned to emp_code (int or varchar) and on wht basis.......since both is possible...
help appreciated
cheers
View 1 Replies
View Related
Jan 2, 2001
hi, can I have a composit primary key which have more than one data type. for instance job_id int,job_type varchar(20)... thanks
Al
View 1 Replies
View Related
Apr 12, 2007
I have several tables in a deployed database in which the primary key is of type int, and autoincrements by 1 each time a record is added. My question is, since ints are 32-bit, what happens when its value reaches 4,294,967,296? I know that seems like an extrememly large amount of records, but when we imported the data into the database it started at key value 1,000,000. I don't know how to make it use lower numbers which are currently not being used (numbers below 1,000,000), and I am worried I will have problems when I reach the upper bound. What kind of problems could this cause? Should I change the primary key's type?Thanks!
View 2 Replies
View Related
May 14, 2012
I have a table with plant types and plant names. Certain plants are grouped on a custom field, currently called Field. I am trying to create a query that will give me a result set containing the primary order on Type, but need items with the same 'Field' value grouped by each other.For example, the following shows a standard query result with "order by Type", ie select * from plants order by Type
Code:
ID Type Name Field
1 Type1Name1(group1)
2 Type2Name2(group2) -group2
3 Type3Name3(group3)
4 Type4Name4(group4)
5 Type5Name5(group2) -group2
6 Type6Name6(group6)
But I want it to look like this, with fields of the same value located next to each other in the result set (but still initially ordered by Type)
Code:
1 Type1Name1(group1)
2 Type2Name2(group2) -group2
5 Type5Name5(group2) -group2
3 Type3Name3(group3)
4 Type4Name4(group4)
6 Type6Name6(group6)
View 7 Replies
View Related
May 27, 2008
Hey, quick question here. In my database for my webapp (The one I showed you guys in my previous post), in my stickies table, I am using a column called StickyId for the PK, and it is of type int. My concern is that eventually, I may get to a point with more then 2 million records in the stickies field. I am looking at using the bigint datatype for StickyId instead, but it takes up twice the memory. So I have two questions:1. Can I declare the StickyId column as type int for now, and if my DB ever starts approaching the 2 million mark, access my DB and change it over to a bigint type? Aka, will MS SQL convert the exisiting int values into a bigint and be transparent to the app and the users?2. Does the bigint always use 8 bytes to store its value? Aka does it pad, so that if I stored the value of '1' would that take the same space as if I stored the value '43563636'? Or is it more like varchar, only taking up the space that that particular value needs?Thanks in advance guys!
View 3 Replies
View Related
Mar 18, 2008
Hi there! My question is: I use a bigint data type as a primary key in my database, so
1. Can I define bigint autoincrement as unsigned?
2. In case of possible, what type should I use in C# code that equal to bigint unsigned - ulong?
3. In case of impossible, what type should I use in C# code - long?
Thanks
View 7 Replies
View Related
Sep 23, 2007
i am creating an application which the number of records will be beyond 100000 so i need to set the primary keys to bigint instead of int
i need to know about the performance and difference
will it affect the performance much and second will i have to change any code like delete,update
View 3 Replies
View Related
Mar 10, 2008
I am using bigint as a primary key. What happens when bigint reaches the maximum number that it can hold?
The Yak Village Idiot
View 8 Replies
View Related
Jan 2, 2008
I want to write the following query.
SELECT CASE WHEN Member.CuApplicationDocFK = 'NULL' THEN 'Existing' ELSE 'New' END AS MemberType
FROM Member
But the problem is Member.CuApplicationDocFK is bigint type. When I run the query it gives a error message saying "error converting data type varchar to bigint.
Can anyone tell me how to fix this please?
Thanks
View 5 Replies
View Related
Oct 4, 2006
The documentation seems to suggest that I can store either a signed or unsigned value in bigint. If I want to store an unsigned value how do I go about it?
View 2 Replies
View Related
May 20, 2008
This select qry runs for abt 20 mins, I think convert to bigint is causing the slowness. Underlying tbl has abt 50000 recs. Pl note that I am runnign this in SQL SERVER 2005, Where it takes abt 20 mins. However when I run this on SQL Server 2000, it takes only 4 mins.
ANy ideas to speed up this qry.
select distinct convert(bigint,c.loannum) as loannum ,c.ampsstatus ,((convert(char(10),c.insdate,110) )) as MaxInsdate
from Conversion_AllStatus_History2007 c
where ((convert(char(10),c.insdate,110) )) =(select max((convert(char(10),a.insdate,110) )) from
Conversion_AllStatus_History2007 a
where convert(bigint,a.loannum)=convert(bigint,c.loannum))
View 3 Replies
View Related
Mar 23, 2012
I am new SQL Server, I have below Timestamp conversion running in Oracle how do I convert same in SQL Server
Default date - 01/01/1970
Application stores Date as bigint - 1326310811062
(TIMESTAMP('01/01/1970', '00:00:00') + (1326310811062 / 1000) SECONDS) AS CREATION
View 7 Replies
View Related
Apr 15, 2004
Hi All,
i wonder if i can get an bigint autoincrement field where the number begins with the current year + 1 autonumber
Does someone know if it is possible and if yes, how?
Already thanx.
Cheers Wim
View 10 Replies
View Related
Jul 23, 2005
I have an SQL back-end with and Access front end. A table in my SQL db hasan auto-num field (integer) that has exceded 70000+ entries. I can add nomore to this table unless I convert that field from INT to BIGINT. Ofcourse, Access doesn't seem to know what a BIGINT is... suggestions?
View 3 Replies
View Related
Nov 22, 2006
I am attempting to build our first set of packages populating or DW. All of our source system primary keys are bigints (on the main tables at least). SSIS seems to have a problem dealing with bigint values, i.e. having to assign variables as doubles rather than int64, having to cast returning bigint values as float, or bigint sproc output parameters as double. It is all a bit messy (and possibly the most frustrating part of SSIS for me) - does anyone know if this problem is due to be fixed in any forthcoming release?
View 2 Replies
View Related
Nov 24, 2003
I just discovered that a bigint column in one of my tables is getting it's values truncated when I run a DTS job to copy the data to another database. The DTS job is designed to refresh our test environments from our production database. All the other tables copy fine. This include another table that also contains a bigint column. But this one table consistenly has a problem where 60 or so records are translated from positive number to negative values. The only explaination I came up with was truncation at some point.
Anyone know of a way to fix or work around this?
View 3 Replies
View Related
Apr 20, 2007
this is more of a theoretical question and not necessarily for best practice...though if reliable and efficient, i'd use it.
a lot of my sprocs return xml and are then processed in xslt...so when i need to sort by date (in xslt), i pass the datetime to a function that ultimately returns a bigint...it seems to work, but i'm not 100% confident...
can anyone confirm that the resulting integer values can be relied on for sorting?
function return: cast((cast(@dt as binary(8))) as bigint)
small test:
sql Code:
Original
- sql Code
declare @i int, @d datetime
declare @t table (id int identity, dt datetime, bd binary(8), bi bigint)
set @i=1
set @d = getdate()
while @i between 1 and 20
begin
insert @t(dt, bd, bi)
select
@d,
cast(@d as binary(8)),
cast((cast(@d as binary(8))) as bigint)
set @d = dateadd(mi, @i, @d)
set @i=@i+1
end
select *
from @t
order by bi
DECLARE @i int, @d datetimeDECLARE @t TABLE (id int identity, dt datetime, bd BINARY(8), bi bigint) SET @i=1SET @d = getdate()WHILE @i BETWEEN 1 AND 20BEGIN INSERT @t(dt, bd, bi) SELECT @d, CAST(@d AS BINARY(8)), CAST((CAST(@d AS BINARY(8))) AS bigint) SET @d = dateadd(mi, @i, @d) SET @i=@i+1END SELECT *FROM @tORDER BY bi
View 1 Replies
View Related
May 3, 2007
I am attempting to write a conversion of our product for Compact Edition; we already provide it based on SQL Server. The database interface uses ADO through a Python-win32com adaptor, and has worked fine so far. (Note: *not* ADO.net, just plain old COM)
Now, a curious thing happens. When inserting new data through a Recordset, everything works fine - except for columns defined as bigint. There are no exceptions thrown, but when you read the columns back they contain nothing but zeroes. Do the same to any other column type - I've tried integer, numeric, float, nvarchar and ntext so far, and they all seem to work just fine. It does not seem to be conversion-related either, since I've tested the exact same data to various column types. And using bigint on regular SQL Server works just fine.
The code involved is quite unspectacular, and simply switching the column types to integer would solve the immediate problem, but causes potential future issues since we normally store internal IDs in bigint columns, and the values may grow quite large.
View 1 Replies
View Related
Sep 11, 2006
Hello
Which variable type in SSIS maps to bigint in SQL Server 2005?
I am returning a single column value of type bigint from SQL Server and want to store that in a varible in SSIS, what datatype should I use?
I tried Int32, Int64, Uint64 and it did not work. Did I do something wrong?
Thanks
View 1 Replies
View Related
Jun 8, 2015
I've got a problem: in few months from now my IDs (int) will reach max positive value. The only viable solution is to convert int-s to bigint-s.
There is a story behind this but I believe it's irrelevant. Simply, I need to 'upgrade' int-s to bigint-s; let's take it as a fact.
Question is: is there a formula to calculate increase in disk and RAM consumption? If we presume I'd need to have same number of pages in buffer cache, how can I calculate how much more memory I need?
Just to ease calculation, let's suppose that I have single table with 1e6 rows and 3 columns:
ID (int), PARENT_ID (int) and NAME (NVARCHAR(30)).Â
PK is on ID (let's call it PK_ID) and there are 2 indexes on PARENT_ID (i.e. IX_PARENT) and NAME (IX_NAME).
Now, if I turn int-s into bigint-s and still want to keep entire table in cache, how I can calculate how much memory I'd need?
View 5 Replies
View Related
Jun 11, 2007
I've recently been struggling with moving a bigint data result from a query into an SSIS variable through the Execute SQL Task. Now, I could just be doing this incorrectly, but I couldn't get it to work at all if I made the variable int64 in SSIS. So here's what I found:
1. bigint from the query into int64 SSIS variable doesn't work at all. It fails.
2. bigint from the query into string SSIS variable works. BUT, it truncates it. And it's a crazy result, at least to me. All of a sudden the number 840550000000000 becomes 8405500000. Now, that's a really unexpected result to me. It seems to me this is a pretty crazy result.
3. Now, if I cast the bigint to varchar in the query and put it into a string SSIS variable, it works perfectly.
Is this a bug? If not, how is this expected behavior? Or maybe I'm just nuts after hours of futzing with this.
Thanks,
Michael
View 14 Replies
View Related
Aug 21, 2006
Hi ,
I have a hexadecimal string value. I want to convert it to Bigint in Sql Server 2005.
The Hexadecimal value is '0x000000000000000F'.
How is it possible to convert into Bigint.
Please help me
Thanks in advance
Srinivas
View 6 Replies
View Related
May 9, 2006
Please help me on this one.
I need to return a value to VB.
I've tried returning a numeric value NUMERIC(25,20) via an output parameter but this didn't work. I'm know at a point in wich I created a bigint and multiplied the value so that the decimals are gone. However it only returns NULL?!?!?!?!!?!?
Here's part of my stored proc
CREATE PROCEDURE dbo.uspCalcWeightedAverage @StartDate2 varchar(10), @EndDate2 varchar(10), @InMarket nvarchar(50), @InProductType int, @InWeekDay int, @WeightedAverage bigint OUTPUTAS......SELECT @WeightedAverage = cast(10000000000 * (SUM(HHF.FACTOR) / COUNT(PDF.FLAG)) as bigint)FROM TBL_PRODUCTDEFS PDF INNER JOIN #DATESBETWEENINTERVAL DBI ON DATEPART(HH, [DBI].[DATE]) = [PDF].[HOUR] INNER JOIN tbl_historichourlyfactors HHF ON DATEPART(D,DBI.DATE) = HHF.DayID AND [PDF].[HOUR] = [HHF].[HOUR] AND DATEPART(M,DBI.DATE) = [HHF].[Month]WHERE PDF.MARKETID = @InMarketID AND PDF.PRODUCTTYPEID = @InProductTypeID AND [PDF].[WD-WE] = @InWeekDay AND HHF.MARKETID = @InMarketID AND PDF.FLAG = 1GROUP BY FLAG
When I retrieve the output param it returns a NULL value. the properties in VB say that the parameter has the following props:
attribute 64 (Long)
NumericScale 0 (Byte)
Precision 19 (Byte)
Size 0 (ADO_LNGPTR)
Type adBigInt
Value Null
I try to return it with the following code (got the code from a friend)
Public Function RunProcedure(ByVal v_strStoredProcName As String, ByRef r_varParamValues() As Variant) As ADODB.RecordsetDim objAdoRecordset As ADODB.RecordsetDim objAdoCommand As ADODB.CommandDim lngCtr As Long On Error GoTo RunCommand_Error ' Create cmd object Set objAdoCommand = New ADODB.Command Set objAdoCommand.ActiveConnection = m_oAdoConnection objAdoCommand.ActiveConnection = m_oAdoConnection objAdoCommand.CommandText = v_strStoredProcName objAdoCommand.CommandType = adCmdStoredProc Call objAdoCommand.Parameters.Refresh 'Stop For lngCtr = 0 To UBound(r_varParamValues) If objAdoCommand.Parameters(lngCtr + 1).Direction = adParamInput Then objAdoCommand.Parameters(lngCtr + 1).Value = r_varParamValues(lngCtr) End If Next Set objAdoRecordset = New ADODB.Recordset objAdoRecordset.CursorLocation = adUseClient Set objAdoRecordset = objAdoCommand.Execute 'Stop For lngCtr = 0 To objAdoCommand.Parameters.Count - 1 If objAdoCommand.Parameters(lngCtr).Direction = adParamOutput Or objAdoCommand.Parameters(lngCtr).Direction = adParamInputOutput Then r_varParamValues(lngCtr - 1) = objAdoCommand.Parameters(lngCtr).Value End If Next Set RunProcedure = objAdoRecordsetRunCommand_Exit: ' Collect your garbage here Exit FunctionRunCommand_Error: ' Collect your garbage here Call g_oGenErr.Throw("WeatherFcst.CDbsConn", "RunCommand")End Function
PLEASE HELP.
Regards,
Sander
View 1 Replies
View Related