Hi there,
I am trying to create a UID that is unique within my SQL Server. There are many users accessing the Server in seperate databases, but then I want to combine all the data from these tables, keeping the ID from each one as a primary key.
I have written the following function, but when i call it as a default value for a field, it does not produce a unique number.
CREATE FUNCTION GETNEXTID(@.CURDATE DATETIME)
RETURNS BIGINT
AS
BEGIN
RETURN (SELECT CAST(
CAST(DATEPART(YY,@.CURDATE) AS VARCHAR) +
RIGHT('0' + CAST(DATEPART(M,@.CURDATE) AS VARCHAR),2) +
RIGHT('0' + CAST(DATEPART(D,@.CURDATE) AS VARCHAR),2) +
RIGHT('0' + CAST(DATEPART(HH,@.CURDATE) AS VARCHAR),2) +
RIGHT('0' + CAST(DATEPART(SS,@.CURDATE) AS VARCHAR),2) +
RIGHT('00' + CAST(DATEPART(MS,@.CURDATE) AS VARCHAR),3) AS BIGINT))
END
Can anyone help?I would create a table as follows:
Create Table DatabaseId
(
DBId Int Identity,
DBName vachar (40) NOT NULL
)
When you import data from the different databases, prefix your unique identifier with DBId. That should give you an unique number across the DB's.|||Take a look at newid()
Showing posts with label accessing. Show all posts
Showing posts with label accessing. Show all posts
Tuesday, March 27, 2012
Wednesday, March 7, 2012
CPU Time required for acessing the sql server database from VC++ application
Hi All,
I am not sure whether i can post this qn. in this sql server forum.
I am accessing the sql server database from a VC++ application. I saw
that when the below statements are taking a CPU time of anywhere
between 5 to 15 %. I think some thing is wrong here..
myRecordSet.Open() //This is taking around 5 to 6 %of CPU time
similary the statement myRecordSet.Addnew() as well, is taking lot of
CPU time.
Why does it need so much of CPU time ?.Appreciate your inputs on this
Thanks
VanithaAre you monitoring CPU on the client or the server?
<vanisathish@.gmail.com> wrote in message
news:1126061226.918105.220330@.g43g2000cwa.googlegroups.com...
> Hi All,
> I am not sure whether i can post this qn. in this sql server forum.
> I am accessing the sql server database from a VC++ application. I saw
> that when the below statements are taking a CPU time of anywhere
> between 5 to 15 %. I think some thing is wrong here..
> myRecordSet.Open() //This is taking around 5 to 6 %of CPU time
> similary the statement myRecordSet.Addnew() as well, is taking lot of
> CPU time.
> Why does it need so much of CPU time ?.Appreciate your inputs on this
> Thanks
> Vanitha
>
I am not sure whether i can post this qn. in this sql server forum.
I am accessing the sql server database from a VC++ application. I saw
that when the below statements are taking a CPU time of anywhere
between 5 to 15 %. I think some thing is wrong here..
myRecordSet.Open() //This is taking around 5 to 6 %of CPU time
similary the statement myRecordSet.Addnew() as well, is taking lot of
CPU time.
Why does it need so much of CPU time ?.Appreciate your inputs on this
Thanks
VanithaAre you monitoring CPU on the client or the server?
<vanisathish@.gmail.com> wrote in message
news:1126061226.918105.220330@.g43g2000cwa.googlegroups.com...
> Hi All,
> I am not sure whether i can post this qn. in this sql server forum.
> I am accessing the sql server database from a VC++ application. I saw
> that when the below statements are taking a CPU time of anywhere
> between 5 to 15 %. I think some thing is wrong here..
> myRecordSet.Open() //This is taking around 5 to 6 %of CPU time
> similary the statement myRecordSet.Addnew() as well, is taking lot of
> CPU time.
> Why does it need so much of CPU time ?.Appreciate your inputs on this
> Thanks
> Vanitha
>
Subscribe to:
Posts (Atom)