UniqueIdentifier Pros And Cons ??

Jul 20, 2005

Hi all
i am building a SQL 2000 database that it is proving a little
challenging, i have companies with multiple addresses, phone numbers,
owning mine sites etc and also joint ventures so maybe you get the
picture with a few design issues that i ma encountering

My queriy is about a primary key identity, and which one to use with
respect to either the identity data type or the unique identifier ,

I am aessentiall building an address table to hold all multiple
addresses as well as phone numbers etc, so my desire to have a unique
identity for each record is very important.

My view is i will run in to violation errors by just using the table
identity data type, i could i suppose use composit primary keys but
that may have a performance impact, although thiis will not be a high
transaction database.

Does anyone know about performance issues regarding each identity
solution, by using a generated 16 bit identifier there are going to be
huge numbers for the DB to verify. or am i worried about nothing?

any views greatly appreciated

regards
Greg

View 17 Replies


ADVERTISEMENT

SQL Server Pros And Cons

May 22, 2002

My company is thinking about moving to a product that uses Microsoft SQL Server and I have been asked to find out what are the Pros and Cons of the product, if any.

Any feedback is appreciated.

Thank You

Pam

View 2 Replies View Related

Upgrade SQL 7 To SQL 2K: Pros And Cons

Aug 13, 2001

Anyone know where I could find some good articles about pros and cons of upgrading SQL 7 to SQL 2K?

Our boss suddenly got this bug up his rear that we need to upgrade. :(
Probably because we are to a point where everything is running smoothly, and he needs to throw a monkey wrench in it.

We are a very small shop, and are not stressing SQL 7 in the least. I am interested to read some articles about SQL 2K, because right now, I can't see any possible reason an upgrade would be worth doing.

Thanks.

View 2 Replies View Related

Pros / Cons To This Approach

Nov 3, 2005

I have a requirement where I need to perform a query for positioninformation. But for some types of entries, I need to "expand" the rowto include additional position rows. Let me explain with an example:An index is a security that is made up of components where eachcomponent has a "weight" or a number of shares. So if I have 1 share ofthe index, I have X shares of each component.AAPL is an Equity, CSCO is an Equity, SPY is an Index. Lets say thatSPY has one component, AAPL, with shares being 10. (1 share of SPY = 10shares of AAPL).So, I do some trading and I end up with positions as follows:+10 AAPL-5 CSCO+2 SPYThe query I need returns:+10 AAPL-5 CSCO+2 SPY+20 AAPL (from 2 SPY * 10 shares)which becomes (after grouping):+30 AAPL-5 CSCO+2 SPY-----------------------------------------Based on that criteria and the following schema (and sample data):-- Drop tablesDROP TABLE [SecurityMaster]DROP TABLE [Position]DROP TABLE [IndexComponent]-- Create tablesCREATE TABLE [SecurityMaster] ([Symbol] VARCHAR(10), [SecurityType] VARCHAR(10))CREATE TABLE [Position] ([Account] VARCHAR(10), [Symbol] VARCHAR(10), [Position] INT)CREATE TABLE [IndexComponent] ([IndexSymbol] VARCHAR(10), [ComponentSymbol] VARCHAR(10), [Shares] INT)--Populate tablesINSERT INTO [SecurityMaster] VALUES ('AAPL', 'Equity')INSERT INTO [SecurityMaster] VALUES ('MSFT', 'Equity')INSERT INTO [SecurityMaster] VALUES ('MNTAM', 'Option')INSERT INTO [SecurityMaster] VALUES ('CSCO', 'Equity')INSERT INTO [SecurityMaster] VALUES ('SPY', 'Index')INSERT INTO [Position] VALUES ('001', 'AAPL', 10)INSERT INTO [Position] VALUES ('001', 'MSFT', -5)INSERT INTO [Position] VALUES ('001', 'CSCO', 10)INSERT INTO [Position] VALUES ('001', 'SPY', 15)INSERT INTO [Position] VALUES ('001', 'QQQQ', 21)INSERT INTO [Position] VALUES ('002', 'MNTAM', 10)INSERT INTO [Position] VALUES ('002', 'APPL', 20)INSERT INTO [Position] VALUES ('003', 'SPY', -2)INSERT INTO [IndexComponent] VALUES ('SPY', 'AAPL', 25)INSERT INTO [IndexComponent] VALUES ('SPY', 'CSCO', 50)INSERT INTO [IndexComponent] VALUES ('QQQQ', 'AAPL', 33)-- *****************************-- Based on the rules:-- 1) Index positions appear like other positions (account /symbol) pair, but-- its components show up as new rows of account (of index),symbol (equal--to component symbol), position (equal to shares * index position)-- 2) One row for each account / symbol pair (GROUP BY account andsymbol, SUM position)-- Expected output (without grouping) (sorted by account / symbol)-- 001 AAPL 10-- 001 AAPL 375 (component shares * index position) (25* 15) (SPY)-- 001 AAPL 693 (component shares * index position) (33* 21) (QQQQ)-- 001 CSCO 10-- 001 CSCO 750 (component shares * index position) (50* 15) (SPY)-- 001 MSFT -5-- 001 QQQQ 21-- 001 SPY 15-- 002 AAPL 20-- 002 MNTAM 10-- 003 AAPL -50 (component shares * index position) (25* -2) (SPY)-- 003 CSCO -100 (component shares * index position) (50* -2) (SPY)-- 003 SPY -2-- Expected output (with grouping account / symbol) (sorted by account/ symbol)-- 001 AAPL 1078-- 001 CSCO 760-- 001 MSFT -5-- 001 QQQQ 21-- 001 SPY 15-- 002 AAPL 20-- 002 MNTAM 10-- 003 AAPL -50-- 003 CSCO -100-- 003 SPY -2---------------------------------------------Is a UNION the best way to perform the query. What are the pros andcons? What, if any, is a better way?SELECT[Account], [Symbol], SUM([Position]) AS [Position]FROM(SELECT[Account], [Symbol] , [Position]FROM[Position]UNION ALLSELECTP.[Account] , IC.[ComponentSymbol] AS [Symbol] , (P.[Position] *IC.[Shares]) AS [Position]FROM[IndexComponent] ICJOIN[Position] PONP.[Symbol] = IC.[IndexSymbol]) DGROUP BY[Account], [Symbol]ORDER BY[Account], [Symbol]

View 5 Replies View Related

Pros And Cons Of Stored Procedures

Mar 28, 2004

can anyone explain the Pros and Cons of Stored Procedures ??

thanks

View 2 Replies View Related

Pros And Cons Of Using Stored Procedures

Sep 19, 2007

Im about to start converting code to Stored Procedures for all my reports in Reporting Services. I was wondering what the pros and cons of this may be.

View 17 Replies View Related

Network Backup Again - What Are The Pros And Cons

Sep 11, 2007

Thanks for the help on the previous thread.

It seems to me that either by accident or design, SQL Server tends to steer you away from backing up directly over the network.

Are there reasons for not doing this because you obviously don't want to leave your backups on a local drive in case the drive fails?

Some possibilties that I can think of are:-

1. Local drives have faster access times and SQL backups can get quite large. I did a quick test and found that a netwrok backup takes 2 to 3 times longer than it does on a local drive.
2. Backing up on the netwrok could hog too much bandwidth. I haven't tested this and would be surprised it it's true.
3. There could be some reason that you don't want the Server and Agent services running under a domain account but want to leave them on the Local System account. I am not aware of any such reasons by the way.
4. Local drives persumably have a slightly higher availability than network drives. If the server is running, the drive should be available.

View 8 Replies View Related

What Are The Cons And Pros Of Using Nvarchar(max) Versus Ntext?

Apr 4, 2007

Like in the subject: What are the cons and pros of using nvarchar(max) versus ntext?
Does it have something to do with having to enable full text search perhaps in the latter case?

View 2 Replies View Related

Pros/Cons Of Multivalue Database Columns

Jun 27, 2004

I'm just wondering what any pros and cons of using multivalue columns in a database are.

I'm designing a database which will have a column for FABRIC_TYPES_AVAILABLE for a certain FURNITURE_ITEM. Each FURNITURE_ITEM can have multiple FABRIC_TYPES_AVAILABLE of course. So I was just going to store a 2 or 3 digit number of the FABRIC_TYPES_AVAILABLE in that row. So I would have something like....34,24,453,32,23,45,67,65,43,21,21,45.

Anyway....thanks in advance for any information. Links I could read would be great too...b/c I did do a bit of searching, but didnt find much.

View 6 Replies View Related

PROS And CONS Of Seperate Databases For CACHING...

May 9, 2006

I have a main database...for this large Web site...and Im wondering
what would be the PROS and CONS of using another database (located on
the same, or on another SQL Server). Im just thinking this would be
good incase we ever needed to take some load off one of the servers.

Also, we will be integrating Community Server into this Web site. Of
course you know CS adds its own database objects which crowd up our
main database objects.

We were thinking of giving CS its own database also; bad practice, or....it doesn't matter much?

Thank you

View 3 Replies View Related

GUID Pros And Cons (was: Question Mssql2005)

Aug 17, 2006

I was wanting to know. I am making a site that might be come big. And me and this dude are considering pickering abotu GUID. I don't want to use them but he does. And I was wondering what should we do? I know nothing about guids

View 1 Replies View Related

Query Excution Process- Pros And Cons

Jun 15, 2006

vinod writes "Q1>Should I apply filter in sequence(based on primarykey,not null,comparision,between clause) ?

-How to apply filter in correct format,and SQL server internally execute it.
Q2>Should I use 'is not Null' to be put at the last?

Q3>Should I use 'between clause' rather than relation operator i.e(empid>10 and empid<200)

Q4>Does filters of sequence has any impact on the query execution process


table1[pkey1,col1,col2,col3] -->pkey is pkey1
table2[pkey2,pkey1,col11,col12,col13]--->pkey is pkey2, and pkey1 is foreign key

CaseI->select table2.pkey2,table1.col1 ,table2.col12
from table1 inner join table2
on table1.pkey1=table2.pkey1
where (table1.col3>100 and table1.col3<300 ) and table2.pkey1=2020 and table2.col13 is not null

CaseII->select table2.pkey2,table1.col1 ,table2.col12
from table1 inner join table2
on table1.pkey1=table2.pkey1
where (table1.col3 between 101 and 299 ) and pkey1=2020 and table2.col13 is not null"

View 1 Replies View Related

Default Constraint On Columns Pros And Cons?

Oct 26, 2007



Are there any vices to using default constraints on all columns in your table.
For example an Int that defaults to 0
or a char or varchar that defaults to ''

I know that 0 and Null are not the same thing. But if your programs don't have the concept of NULL then you have to convert the NULL to zero.

So, DEFAULT CONSTRAINTS on every column. Is it good or Bad?

Thanks

Darin Clark

View 10 Replies View Related

Saving Files (Binaries) Into Database - Pros And Cons

Jun 19, 2008

Can someone provide information or a link to information regarding the pros and cons of saving files directly into a SQL 2005 database?
I'm actually for saving files to a database (cleaner implementation then just saving the location then having to get the file, etc), but my project manager is not convinced so I need to make an argument for (or against depending on what I actually find out) using varbinary data type.
Thanks.

View 2 Replies View Related

What Are Cons And Pros For Using IDENTITY Property As PK In SQL SERVER 2000?

Jul 20, 2005

Hi All!We are doing new development for SQL Server 2000 and also moving fromSQL 7.0 to SQL Server 2000.What are cons and pros for using IDENTITY property as PK in SQL SERVER2000?Please, share your experience in using IDENTITY as PK .Does SCOPE_IDENTITY makes life easier in SQL 2000?Is there issues with DENTITY property when moving DB from one serverto another? (the same version of SQL Server)Thank you in advance,Andy

View 49 Replies View Related

Storing SSIS Packages Within SQLServer; Pros/cons

Feb 26, 2008

hi all,
I was wondering if anyone knows of any pros/cons on storing SSIS (2005) packages within SQL Server 2005 SP2.
We're contemplating the migration/storage of a large number of packages, a minority of which designed in dts (SQLServer 2000) and using third party activx components.

thanks much for any feedback,
Cosmin

View 3 Replies View Related

Pros And Cons Of Placing Indexes On Separate File Groups

Apr 20, 2001

We are in the process of replacing our primary production server. In the process of determining how SQL server is going to be structured, it has been suggested that I place all current and new indexes on a separate file group. These filegroups would then reside on a separate shelf on the server. What are the pros and cons of doing this?

View 2 Replies View Related

Pros And Cons Of Using Transaction Replication Doing Initialization From Database Backups

Jun 27, 2007



I am using transaction replication between a transaction and reporting database server. When I use a snapshot to initialize my subscribers, I currently get a lot of deadlocks during the snapshot creation. I am considering using a database backup instead. Can anyone tells me how to reduce the table locks that I am getting during snapshot creation or advice on using database backups?



View 1 Replies View Related

Need Help With Project $$ Pros Only

Mar 30, 2008

Hi, I need a help with a SP, professionals only. If you're interested PM/email me please.

View 3 Replies View Related

Maybe Trigger Failed, Deadlock Victim? Pros Click Me!!!

Mar 10, 2000

Let's say I have a trigger on my orders table.

When this fires a query is done on the customer table to get some values
and put some order/customer data into an audit trail table.

In one period of time, it appears that the trigger did not put the data into the separate table. No known reason.

Suspicion: What if the customer table were locked by some process when the trigger fired. Maybe the trigger was chosen as a deadlock-victim.

?? I guess I need to check for @@ERROR during the trigger and do something. Any suggestions? I think I can raise the priority of my trigger to "win" during a deadlock.

If trigger activity is chosen as a deadlock-victim, can the trigger make another attempt to complete it's activity?

View 1 Replies View Related

Uniqueidentifier

Apr 10, 2006

I am really struggling.  I am trying to query a sql database table using a uniqueidentifier. 
Public Class SalesDataClass
Public Function getAccountNumber(ByVal ID As String) As String
Dim accountnumber As String = "0"
'Try
Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("InterhealthCRM_MSCRMConnectionString").ConnectionString)
Using command As New SqlCommand("getAccountNumber", connection)
command.CommandType = CommandType.StoredProcedure
 
Dim parameterdat1 As New SqlParameter("@accountid", SqlDbType.UniqueIdentifier)
parameterdat1.Value = ID
command.Parameters.Add(parameterdat1)
Dim parameterdat2 As New SqlParameter("@accountnum", SqlDbType.NVarChar, 20, ParameterDirection.Output)
command.Parameters.Add(parameterdat2)
connection.Open()
command.ExecuteNonQuery()
accountnumber = parameterdat2.Value
Return accountnumber
 
End Using
End Using
'Catch ex As SqlException
' Catch ex As InvalidOperationException
' Catch ex As Exception
' You might want to pass these errors
' back out to the caller.
' End Try
End Function
End Class
Can someone help me correct my code.
 
Sproc:
ALTER PROCEDURE [dbo].[getAccountNumber]
-- Add the parameters for the stored procedure here
@accountId uniqueidentifier,
@accountnum nvarchar(20) output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT accountNumber from accountbase where accountid = @accountid
return @accountnum
END

View 2 Replies View Related

Uniqueidentifier

Jul 17, 2003

Hi,

I am using UNIQUEIDENTIFIER column for my table. I do not insert data for it. I left it on database by setting to default NEWID(). Now in my application I need the value of UNIQUEIDENTIFIER column I just inserted. Is there any function or query to get this value like in case of IDENTITY column we can get the latest inserted value from select @@IDENTITY.

Thanks and regards,
Uday

View 3 Replies View Related

Uniqueidentifier

Jan 28, 2006

Hey I was curious about the Uniqueidentifier is that better then using the @IDENTITY, apparently the Unique uses your computers mac address as a base???

View 4 Replies View Related

Uniqueidentifier

Dec 5, 2006

as above, how can i use this datatype to generate a running number for my userID ? i tried with newid() but it returns a unique 32bit.

View 10 Replies View Related

Uniqueidentifier

Apr 4, 2008



does SQLCE supports the use of uniqueidentifier datatype.and how can i use it?
i have heard that SQLCE supports only integer type as identity column.
so what datatype i should use for identification(primary key).

View 4 Replies View Related

Uniqueidentifier Inner Join Int

Nov 5, 2007

I have a table with id(uniqueidentifier) as the primary key, and another table with id(int) as the foreign key.
When I try to INNER JOIN them on id=id  in a view, I get an error that uniqueidentifier and int are incompatible.
I'm new to SQL SERVER and I consider uniqueidentifier as equal to AutoNumber in MSAccess. Isn't it so? If not, how do I make this JOIN work?

View 3 Replies View Related

Uniqueidentifier And Combobox

Nov 26, 2007

Hello all,
I would like to put another line into my combo box using this SQL statement but this part "(select newid() as QuestionID, 'Select a Question' as QuestionText)" is not working.   (select newid() as QuestionID, 'Select a Question as QuestionText) union all (SELECT * FROM (SELECT TOP 100 * FROM [dbo.aspnet_Questions]) as tbl)
RETURN
It gives me an error: Invalid object name 'dbo.aspnet_Questions'.  Can anybody please help me with this error? 
Thank you, Vic. 

View 5 Replies View Related

Uniqueidentifier URGENT PLEASE!

Jan 26, 2008

I just want to ask if there is a passible explaination for why this code thosen't generate the proper RETURN VALUE, My coal is when a user uses the asp:CreateUserWizard i retrive GUID from the new account.With this I will check if the relation tabel has that value, so I would like to run this.
Stored Proc.
CREATE PROCEDURE proc_CustomerCheckExist@UserId uniqueidentifierASIF EXISTS (SELECT COUNT(*) FROM dbo.aspnet_LD_Customers WHERE UserId = @UserId)    Return 1ELSE    Return 0GO
Problem is if I take 2 different GUID, I still get the same result "Return 1" as true even if I dont have the GUID in my tabel row
Thanks!

View 3 Replies View Related

How Do I Get The Uniqueidentifier Of Just Inserted Row?

Apr 18, 2004

Hello there!

it was a while since i studied SQL and that brings us to my problem...

I'm creating a Stored Procedure wich first insert information in a table. That table has a uniqueidentifier fild that is default-set to newid().

later in the SP i need that uniqueidentifier value? how do I get it?

I tried this:

CREATE PROCEDURE spInsertNews
@uidArticleId uniqueidentifier = newid,
@strHeader nvarchar(300),
@strAbstract nvarchar(600),
@strText nvarchar(4000),
@dtDate datetime,
@dtDateStart datetime,
@dtDateStop datetime,
@strAuthor nvarchar(200),
@strAuthorEmail nvarchar(200),
@strKeywords nvarchar(400),
@strCategoryName nvarchar(200) = 'nyhet'
AS
INSERT INTO tblArticles
VALUES( @uidArticleId,@strHeader,@strAbstract,@strText,@dt
Date,@dtDateStart,@dtDateStop,@strAuthor,@strAutho
rEmail,@strKeywords)

declare @uidCategoryId uniqueidentifier
EXEC spGetCategoryId @strCategoryName, @uidCategoryId OUTPUT

INSERT INTO tblArticleCategory(uidArticleId, uidCategoryId)
VALUES(@uidArticleId, @uidCategoryId)


But i get an error when I EXEC the SP like this:

EXEC spInsertNews
@strHeader = 'Detta är den andra nyheten',
@strAbstract = 'dn första insatt med sp:n',
@strText = 'här kommer hela nyhetstexten att stå. Här får det plats 2000 tecken, dvs fler än vad jag orkar skriva nu...',
@dtDate = '2003-01-01',
@dtDateStart = '2003-01-01',
@dtDateStop = '2004-01-01',
@strAuthor = 'David N',
@strAuthorEmail = 'david@davi.com',
@strKeywords = 'nyhet, blajblaj, blaj'


the errormessage is: Syntax error converting from a character string to uniqueidentifier.


does anyone have a sulution to this problem?
Can I use something similar to the @@IDENTITY?
I will be greatful for any ideas...

thanks
/David, Sweden

View 8 Replies View Related

Ok To Concat A Uniqueidentifier?

Jul 8, 2004

I want to use a NEWID() to generate order numbers, but i dont want to give customers the long uniqueID. so im wondering if i concatinate it to 8 characters, if that would be safe or not...

thx in adv

View 6 Replies View Related

Return A UNIQUEIDENTIFIER

Feb 9, 2005

Hi,

I am writing a C# application that uses a SQL server database to hold its data. I need to create a stored procedure that returns a particular row's primary key value. This is no problem if the primary key is an INT. But my primary key is a unique identifier, and the stored procedure doesn't want to let me return any values that aren't INTs. Can someone please tell me how to get around this?

Thanks in advance.

Scott

View 3 Replies View Related

Problem With SP And Uniqueidentifier

Nov 28, 2005

I am trying to use a stored procedure and it seems to be giving me a error - I think it doesn't like the uniqueidentifier.   I have included the error, stored procedure, and code behind that calls the stored procedure.Thanks for any help on this!  This is the error I get:System.ArgumentException: No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type. at System.Data.SqlClient.MetaType.GetMetaTypeFromValue(Type dataType, Object value, Boolean inferLen) at System.Data.SqlClient.SqlParameter.GetMetaTypeOnly() at System.Data.SqlClient.SqlParameter.Validate(Int32 index) at System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters) at System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at view_WardSec_PatientLogDetail2.UpdateRecord_buttonClick(Object sender, EventArgs e) in C:Documents and SettingsKBuchanan.LMHDesktopWebSitesNewest_ERViewsview_WardSec_PatientLogDetail.aspx.vb:line 358 Here is the stored procedure:set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgo
ALTER PROCEDURE [dbo].[UpdateTblVisit_WardSecPatientLog]  ( @VID decimal, @lbl_ChiefComplaint nvarchar(50),  @TriageDtTmTextBox datetime,  @PtInRmDtTmTextBox datetime,  @RnInRmDtTmTextBox datetime,  @PhyInRmDtTmTextBox datetime,  @EDHoldDisposDtTmTextBox datetime,  @DispDschDtTmTextBox datetime,  @ddlTriageNurse uniqueidentifier,  @ddlPriNurse uniqueidentifier,  @ddlEDPhy uniqueidentifier,  @ddlPriRefPhy decimal,  @ddlSecRefPhy decimal,  @ddlDschRN uniqueidentifier,  @ddlDschPhy uniqueidentifier,  @ddl_MnsArriv decimal,  @lblDschDiag nvarchar(50),  @chkbox_LogComplete bit )AS
SET NOCOUNT ON
 Update   tblVisit  SET  vChiefComplaint = @lbl_ChiefComplaint,   vTriageDtTm = @TriageDtTmTextBox,   vPtInRmDtTm = @PtInRmDtTmTextBox,   vRnInRmDtTm = @RnInRmDtTmTextBox,   vPhyInRmDtTm = @PhyInRmDtTmTextBox,   vEDHoldDisposDtTm = @EDHoldDisposDtTmTextBox,   vDispDschDtTm = @DispDschDtTmTextBox,   vTriageRnID = @ddlTriageNurse,   vRnID = @ddlPriNurse,   vEdPhyProvID = @ddlEDPhy,   vPriRefPhyProvID = @ddlPriRefPhy,   vSecRefPhyProvID = @ddlSecRefPhy,   vDschRnID = @ddlDschRN,   vDschPhyID = @ddlDschPhy,   vMnsArrvID = @ddl_MnsArriv,   vDschDiag = @lblDschDiag,   vLogCompletedInd = @chkbox_LogComplete,   vLogLastEdit = getDate() WHERE   VID = @VID    SET NOCOUNT OFF RETURN
-----------------------------------------------------------------------------Following is the codebehind for a button oncommand event.  This codeshould execute the stored procedure.-----------------------------------------------------------------------------
    Public Sub UpdateRecord_buttonClick(ByVal sender As Object, ByVal e As System.EventArgs)        'Use this to update the CareGiverID into the tbl_Visit table.        Dim sbSql As New System.Text.StringBuilder        sbSql.Append("EXEC UpdateTblVisit_WardSecPatientLog ")        sbSql.Append("@VID, ")        sbSql.Append("@lbl_ChiefComplaint, ")        sbSql.Append("@TriageDtTmTextBox, ")        sbSql.Append("@PtInRmDtTmTextBox, ")        sbSql.Append("@RnInRmDtTmTextBox, ")        sbSql.Append("@PhyInRmDtTmTextBox, ")        sbSql.Append("@EDHoldDisposDtTmTextBox, ")        sbSql.Append("@DispDschDtTmTextBox, ")        sbSql.Append("@ddlTriageNurse, ")        sbSql.Append("@ddlPriNurse, ")        sbSql.Append("@ddlEDPhy, ")        sbSql.Append("@ddlPriRefPhy, ")        sbSql.Append("@ddlSecRefPhy, ")        sbSql.Append("@ddlDschRN, ")        sbSql.Append("@ddlDschPhy, ")        sbSql.Append("@ddl_MnsArriv, ")        sbSql.Append("@lblDschDiag, ")        sbSql.Append("@chkbox_LogComplete, ")        sbSql.Append("@UserID ")
        'Response.Write(sbSql.ToString)        'Response.End()
        'Create variables for each of the edited values        Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("ERTrekker_ProdConnectionString1").ConnectionString)        Dim cmd As New SqlCommand(sbSql.ToString(), con)
        FindControls(DetailsView, "lbl_ChiefComplaint")        Dim ilbl_ChiefComplaint As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "TriageDtTmTextBox")        Dim iTriageDtTmTextBox As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "PtInRmDtTmTextBox")        Dim iPtInRmDtTmTextBox As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "RnInRmDtTmTextBox")        Dim iRnInRmDtTmTextBox As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "PhyInRmDtTmTextBox")        Dim iPhyInRmDtTmTextBox As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "EDHoldDisposDtTmTextBox")        Dim iEDHoldDisposDtTmTextBox As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "DispDschDtTmTextBox")        Dim iDispDschDtTmTextBox As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "ddlTriageNurse")        Dim iddlTriageNurse As DropDownList = CType(MyControl, DropDownList)        FindControls(DetailsView, "ddlPriNurse")        Dim iddlPriNurse As DropDownList = CType(MyControl, DropDownList)        FindControls(DetailsView, "ddlEDPhy")        Dim iddlEDPhy As DropDownList = CType(MyControl, DropDownList)        FindControls(DetailsView, "ddlPriRefPhy")        Dim iddlPriRefPhy As DropDownList = CType(MyControl, DropDownList)        FindControls(DetailsView, "ddlDschRN")        Dim iddlDschRN As DropDownList = CType(MyControl, DropDownList)        FindControls(DetailsView, "ddlDschPhy")        Dim iddlDschPhy As DropDownList = CType(MyControl, DropDownList)        FindControls(DetailsView, "ddl_MnsArriv")        Dim iddl_MnsArriv As DropDownList = CType(MyControl, DropDownList)        FindControls(DetailsView, "lblDschDiag")        Dim ilblDschDiag As TextBox = CType(MyControl, TextBox)        FindControls(DetailsView, "chkbox_LogComplete")        Dim ichkbox_LogComplete As CheckBox = CType(MyControl, CheckBox)
        'Add all of the parameters to the command        With cmd.Parameters            .AddWithValue("@VID", Request("vID"))            .AddWithValue("@lbl_ChiefComplaint", ilbl_ChiefComplaint.Text.ToString)            .AddWithValue("@TriageDtTmTextBox", iTriageDtTmTextBox.Text.ToString)            .AddWithValue("@PtInRmDtTmTextBox", iPtInRmDtTmTextBox)            .AddWithValue("@RnInRmDtTmTextBox", iRnInRmDtTmTextBox.Text.ToString)            .AddWithValue("@PhyInRmDtTmTextBox", iPhyInRmDtTmTextBox.Text.ToString)            .AddWithValue("@EDHoldDisposDtTmTextBox", iEDHoldDisposDtTmTextBox.Text.ToString)            .AddWithValue("@DispDschDtTmTextBox", iDispDschDtTmTextBox.Text.ToString)            .AddWithValue("@ddlTriageNurse", iddlTriageNurse.SelectedValue.ToString)            .AddWithValue("@ddlPriNurse", iddlPriNurse.SelectedValue.ToString)            .AddWithValue("@ddlEDPhy", iddlEDPhy.SelectedValue.ToString)            .AddWithValue("@ddlPriRefPhy", iddlPriRefPhy.SelectedValue.ToString)            .AddWithValue("@ddlDschRN", iddlDschRN.SelectedValue.ToString)            .AddWithValue("@ddlDschPhy", iddlDschPhy.SelectedValue.ToString)            .AddWithValue("@ddl_MnsArriv", iddl_MnsArriv.SelectedValue.ToString)            .AddWithValue("@lblDschDiag", ilblDschDiag.Text.ToString)            .AddWithValue("@chkbox_LogComplete", ichkbox_LogComplete.Checked.ToString)            .AddWithValue("@UserID", System.Web.HttpContext.Current.Session("UserID"))
        End With
        ' Open the connection and execute the command        Try            con.Open()            If cmd.ExecuteNonQuery() < 1 Then                Throw New System.Exception("The record was not updated")            End If        Catch ex As Exception            System.Web.HttpContext.Current.Response.Write(ex.ToString())        Finally            If Not con Is Nothing AndAlso con.State = System.Data.ConnectionState.Open Then                con.Close()            End If        End Try    End Sub

View 1 Replies View Related

Foreign Key Is An Uniqueidentifier

Nov 10, 2005

Hello everyone.
I have 2 tables in MSSQL Server 2000, Products(idProduct, idProductType, name, quatity) and ProductsType(idProductType, name).

idXXXX are the primery keys and the data type is uniqueidentifier.

In table Products, the collum idProductType is a foreign key refering table ProductsType.

I can insert as many product types as i want without any problems.
Insert INTO ProductsType(name) VALUES('milk')

When inserting products i use the idProductType that was automatacly generated in last insert.
INSERT INTO Products (uuidProductType,name,quantity,)
VALUES ('AD9388A3-CA86-482D-B57F-6FA068E7D405','President Milk 50cl',500)

but i got the following error in SQL Query Analyzer:
Server: Msg 8169, Level 16, State 2, Line 1
Syntax error converting from a character string to uniqueidentifier.

I have searched the forum and i cant find any solution. i need to use uniqueidentifer data types because replication with PDA devices.

Any tips?

Thank you in advance.
Helder

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved