Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Syntax error converting from a character string to

Author  Topic 

toddhd
Yak Posting Veteran

55 Posts

Posted - 2006-02-13 : 11:17:46
I keep getting this error while trying to insert Guid's into my DB. The Guid's are being supplied by another source, so I cannot use the NewID() function here. I read on other posts that I should simply read the value in as a string, and then Cast/Convert it to a Guid, which I believe I am doing correctly below, but I am still getting this error message! I am on a very tight deadline and freaking out, so any help would be greatly appreciated. Thank you.

Here is my test in Query Analyzer:
InsertAdaptLibPackage
@Language = '',
@PackageName = 'Property Gadget Maintenance',
@PackageType = '0',
@PackageDesc = '',
@CategoryCode = '',
@VersionNote = '',
@AdaptAuthor = '',
@AppName = 'eSource',
@AppVersion = '3.0.0',
@ClientName = 'Morley Companies, Inc.',
@ImplementDate = '1/1/1753',
@UserID = 'ATLCES\TDavis',
@ModUserID = 'ATLCES\TDavis',
@DateAdd = '1/1/1753',
@DateMod = '1/1/1753',
@Deleted = '0',
@DateLastExport = '1/1/1753',
@PackageID = '{0C4A6CD3-0679-43C1-946C-74DFA43AF299}',
@PackageVersion = '0'

And here is the SPROC:
CREATE PROCEDURE [dbo].InsertAdaptLibPackage
@Language varchar(10),
@PackageName nvarchar(128),
@PackageType smallint,
@PackageDesc nvarchar(512),
@CategoryCode varchar(6),
@VersionNote nvarchar(512),
@AdaptAuthor nvarchar(128),
@AppName nvarchar(100),
@AppVersion nvarchar(20),
@ClientName nvarchar(256),
@ImplementDate datetime,
@UserID nvarchar(256),
@ModUserID nvarchar(256),
@DateAdd datetime,
@DateMod datetime,
@Deleted bit = NULL,
@DateLastExport datetime = NULL,
--@PackageID uniqueidentifier,
@PackageID varchar,
@PackageVersion float
AS

--SET @PackageID = NEWID()

INSERT INTO [dbo].[AdaptLibPackage] (
[PackageID],
[Language],
[PackageName],
[PackageType],
[PackageDesc],
[CategoryCode],
[VersionNote],
[AdaptAuthor],
[AppName],
[AppVersion],
[ClientName],
[ImplementDate],
[UserID],
[ModUserID],
[DateAdd],
[DateMod],
[Deleted],
[DateLastExport],
[PackageVersion]
) VALUES (
CAST(@PackageID AS uniqueidentifier),
@Language,
@PackageName,
@PackageType,
@PackageDesc,
@CategoryCode,
@VersionNote,
@AdaptAuthor,
@AppName,
@AppVersion,
@ClientName,
@ImplementDate,
@UserID,
@ModUserID,
@DateAdd,
@DateMod,
@Deleted,
@DateLastExport,
@PackageVersion)
GO

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-02-13 : 11:31:17
Make sure the GUID string is valid, and is exactly 36 characters in length.
Go to Top of Page

toddhd
Yak Posting Veteran

55 Posts

Posted - 2006-02-13 : 11:45:32
quote:
Originally posted by blindman

Make sure the GUID string is valid, and is exactly 36 characters in length.


Thanks for your reply. The GUID's are coming from XML files that are exported from another application. They are initially generated by SQL and so should be valid. I double checked my example above, and the GUID listed does appear to be 36 characters in length. I don't know what makes a Guid valid or not (do they have CRC of some kind?) but since it was generated by SQL and appears identical to the one supplied, I am going to assume it is otherwise valid.

Any other ideas? This one is stumping me to no end...
Go to Top of Page

toddhd
Yak Posting Veteran

55 Posts

Posted - 2006-02-13 : 11:50:30
Never mind, folks, I got it. An associate working on a similar problem changed one of the fields from varchar to uniqueidentifier (which I had previously verified and printed out for reference) without notifying anyone. Chalk this up to the left hand working independently of the right hand... argh...
Go to Top of Page
   

- Advertisement -