Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2003, 09:29 AM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default VarChar Problem

Hi
I have the folowing stored proc.

CREATE PROC NewDoc
@Vrsta nvarchar(3),
@Sifra int OUTPUT
AS

INSERT Doc(Vrsta)
VALUES ( @Vrsta)

SELECT @Sifra = @@IDENTITY

declare @sifra int
exec novidokument '06', @sifra output
print @sifra

The field Vrsta in table Doc is varchar(3), but after insert into the table the value in the table is not 06 then 6. The same thing is with everty string containing zero on the begining.
How can i resolve this problem?
Thanks
Alex
 
Old August 28th, 2003, 09:54 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

The value in the varchar field will be stored as '06' if you pass it into the procedure. Try running this piece of code to see :-

CREATE table mytable
(
Vrsta nvarchar(3)
)

INSERT mytable
VALUES ('06')

SELECT * from mytable


In your procedure you are only retrieving the identity column value.

Try selecting the data in your 'Doc' table to see exactly whats in there.

Nickie
 
Old August 28th, 2003, 10:06 AM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your script work fine
but please try mine and you'll see that is not working if you select after inserting from table Doc
 
Old August 28th, 2003, 10:13 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I have tried your script and selected from 'Doc' table and my result is :-

Vrsta Sifra
----- -----------
06 1

Nickie





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem converting datatype text to varchar kwilliams SQL Server 2000 4 August 15th, 2008 07:59 AM
Syntax error converting the varchar value... Earl Hickey ASP.NET 2.0 Basics 5 January 23rd, 2008 10:25 PM
The conversion of the varchar value '2110000000000 vitthala SQL Server 2000 7 July 1st, 2006 10:26 AM
The conversion of the varchar value '2110000000000 vitthala Pro Visual Basic 2005 1 June 30th, 2006 01:37 PM
change nvarchar to varchar vincentc SQL Server 2000 3 May 24th, 2005 10:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.