SQL 2008 Query Help
-
Why would this simple select error like this: sql 2008? SELECT field1 FROM ADDRESS where field1 != 'NULL' "Error Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to numeric." The real goal is to get this select to work but there are two fields causing me problems. The two fields commented out are generating the same error as above....how would I insert a cast into the below query for fields 4 and 5? use dbname Select field1 + ' ' + ISNULL(field2,'') + ' ' + ISNULL(field3,'') --+ ' ' + ISNULL(field4,'') --+ ' ' + ISNULL(field5,'') as column_new from table1 Error converting data type varchar to numeric."
Regards, Hulicat
-
Why would this simple select error like this: sql 2008? SELECT field1 FROM ADDRESS where field1 != 'NULL' "Error Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to numeric." The real goal is to get this select to work but there are two fields causing me problems. The two fields commented out are generating the same error as above....how would I insert a cast into the below query for fields 4 and 5? use dbname Select field1 + ' ' + ISNULL(field2,'') + ' ' + ISNULL(field3,'') --+ ' ' + ISNULL(field4,'') --+ ' ' + ISNULL(field5,'') as column_new from table1 Error converting data type varchar to numeric."
Regards, Hulicat
Hulicat wrote:
SELECT field1 FROM ADDRESS where field1 != 'NULL'
select field1 from ADDRESS where field1 is not null
Hulicat wrote:
how would I insert a cast into the below query for fields 4 and 5?
select cast(field5 as varchar)
I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!
-
Hulicat wrote:
SELECT field1 FROM ADDRESS where field1 != 'NULL'
select field1 from ADDRESS where field1 is not null
Hulicat wrote:
how would I insert a cast into the below query for fields 4 and 5?
select cast(field5 as varchar)
I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!
Thanks for the reply. I am having an issue inserting the cast into this statement for feilds 4, 5: use dbname Select field1 + ' ' + ISNULL(field2,'') + ' ' + ISNULL(field3,'') --+ ' ' + ISNULL(field4,'') --+ ' ' + ISNULL(field5,'') as column_new from table1
Regards, Hulicat
-
Thanks for the reply. I am having an issue inserting the cast into this statement for feilds 4, 5: use dbname Select field1 + ' ' + ISNULL(field2,'') + ' ' + ISNULL(field3,'') --+ ' ' + ISNULL(field4,'') --+ ' ' + ISNULL(field5,'') as column_new from table1
Regards, Hulicat
Hulicat wrote:
I am having an issue inserting the cast into this statement for feilds 4, 5:
I already gave you that answer... Here it is in total since you seem to have not understood what I was talking about... use dbname Select field1 + ' ' + ISNULL(field2,'') + ' ' + ISNULL(field3,'') + ' ' + cast(field4 as varchar) + ' ' + cast(field5 as varchar) as column_new from table1
I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!
-
Thanks for the reply. I am having an issue inserting the cast into this statement for feilds 4, 5: use dbname Select field1 + ' ' + ISNULL(field2,'') + ' ' + ISNULL(field3,'') --+ ' ' + ISNULL(field4,'') --+ ' ' + ISNULL(field5,'') as column_new from table1
Regards, Hulicat
When you use the cast as per damians suggestion you need to define the size of the varchar as int
ISNULL(Cast Field4 as varchar(20)),'')
-
When you use the cast as per damians suggestion you need to define the size of the varchar as int
ISNULL(Cast Field4 as varchar(20)),'')
-
When you use the cast as per damians suggestion you need to define the size of the varchar as int
ISNULL(Cast Field4 as varchar(20)),'')
Mycroft Holmes wrote:
you need to define the size of the varchar as int
Interesting... not in SQL-2005 you don't!!
I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!
-
Mycroft Holmes wrote:
you need to define the size of the varchar as int
Interesting... not in SQL-2005 you don't!!
I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!
I am using 2008 and checked BOL before posting, I use Convert almost exclusively so I had to check, maybe the doco is out of date?
-
I am using 2008 and checked BOL before posting, I use Convert almost exclusively so I had to check, maybe the doco is out of date?
Maybe... I did it with SQL2005 before posting... don't have SQL2008 here...
I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!