-
convert question revisited
hi,
I guess my brain isn't functioning on monday morning. I am trying to do a convert with little success.
what I want to do is insert a character string into a smallint column of a table. i.e.
DECLARE @a char(6)
select @a = 'string'
I have tried the following and variations on it, but get a syntax error
insert table testtable (1,convert(smallint,@a))
The columns in testtable are both smallint datatypes.
Thanks in advance
-- I got this response, but seem to get a convert error even
when using the below example
Try this :
DECLARE @a char(6),
@b smallint
select @a = 'string'
select @b = convert(smallint, @a)
insert testtable values (1, @b)
any suggestions?
-
convert question revisited (reply)
First of all it's not possible to insert a character into smallint.
if u want to then u have to convert the character value to ascii value and then u have to insert it.
DECLARE @a char(6),
@b int
select @a = 'string'
select @b = convert(int, ascii(@a))
select @b
insert testtable values (1, @b)
Jen
------------
Jerry at 11/20/00 11:18:43 AM
hi,
I guess my brain isn't functioning on monday morning. I am trying to do a convert with little success.
what I want to do is insert a character string into a smallint column of a table. i.e.
DECLARE @a char(6)
select @a = 'string'
I have tried the following and variations on it, but get a syntax error
insert table testtable (1,convert(smallint,@a))
The columns in testtable are both smallint datatypes.
Thanks in advance
-- I got this response, but seem to get a convert error even
when using the below example
Try this :
DECLARE @a char(6),
@b smallint
select @a = 'string'
select @b = convert(smallint, @a)
insert testtable values (1, @b)
any suggestions?
-
convert question revisited (reply)
Thank you,
Jerry
------------
jennifer at 11/20/00 2:43:56 PM
First of all it's not possible to insert a character into smallint.
if u want to then u have to convert the character value to ascii value and then u have to insert it.
DECLARE @a char(6),
@b int
select @a = 'string'
select @b = convert(int, ascii(@a))
select @b
insert testtable values (1, @b)
Jen
------------
Jerry at 11/20/00 11:18:43 AM
hi,
I guess my brain isn't functioning on monday morning. I am trying to do a convert with little success.
what I want to do is insert a character string into a smallint column of a table. i.e.
DECLARE @a char(6)
select @a = 'string'
I have tried the following and variations on it, but get a syntax error
insert table testtable (1,convert(smallint,@a))
The columns in testtable are both smallint datatypes.
Thanks in advance
-- I got this response, but seem to get a convert error even
when using the below example
Try this :
DECLARE @a char(6),
@b smallint
select @a = 'string'
select @b = convert(smallint, @a)
insert testtable values (1, @b)
any suggestions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|