August 24, 2010 at 8:05 pm
Hi Good Guys, :w00t:
I need your help, Please Help me. 😛
he DATABase Administrator is away for 3 months holidays and I was asked to transfer Customer ContactTitle from the TblCustomers Table into a another Table TblContTitleRef and at the SQL QUERY ANALYSER I did not get it right
Here are the SQL String:
Insert into TblContTitleRef (ContactTitle) Values
(select distinct(ContactTitle) from TblCustomers where TblCustomers.ContactTitle <> Null);
These are the error message:
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'select'.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ')'.
Please help me. Thanks.
Have a Good Day.
cheers,
Lennie
August 24, 2010 at 9:53 pm
You are using the wrong syntax
try the following instead
Insert into TblContTitleRef (ContactTitle)
select distinct(ContactTitle) from TblCustomers where TblCustomers.ContactTitle <> Null;
August 24, 2010 at 10:18 pm
Hullo Pussy Cat,
You mentioned that the SQL string I have created have syntax error but you did not provide the correct syntax. So that I can try it out. You could be wrong too.
August 26, 2010 at 4:42 am
Did you actually read my reply - I included the correct code. How about trying that !
August 26, 2010 at 4:08 pm
Hi Pussy Cat,
I did read your earlier statement and found that there is no proper coding.
This is your statement from earlier reply
You are using the wrong syntax
try the following instead
Insert into TblContTitleRef (ContactTitle)
select distinct(ContactTitle) from TblCustomers where TblCustomers.ContactTitle <> Null;
that's the reason why I mentioned that you did not provide sample coding and mentioned that you could be wrong as well.
My SQL string is now working and I would like share it with other Newbies who may have similar problem:
Insert into TblContTitleRef (contactTitle)
Select Distinct(contactTitle)
From TblCustomers
Where (contactTitle is not NULL);
August 26, 2010 at 4:17 pm
Lennie (8/26/2010)
Hi Pussy Cat,I did read your earlier statement and found that there is no proper coding
Um, I don't know what you're reading, but the third and fourth lines of his post have the proper code.
Bolded, to make it clearer:
You are using the wrong syntax
try the following instead
Insert into TblContTitleRef (ContactTitle)
select distinct(ContactTitle) from TblCustomers where TblCustomers.ContactTitle <> Null;
That is not what you posted, which was
Insert into TblContTitleRef (ContactTitle) Values
(select distinct(ContactTitle) from TblCustomers where TblCustomers.ContactTitle <> Null);
Though, I'm not sure that <> Null is going to do what you want, unless the ansi nulls setting is off.
Plus the brackets around the column name (after the distinct) are unnecessary. Distinct is not a function.
p.s. there's no one by the name 'pussy cat' here.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 26, 2010 at 4:29 pm
One of the help name is pussycat59.
If you look at the earlier responds you will notice it.
Make it your practice to view earlier posting inorder to understand the problem
August 26, 2010 at 4:33 pm
Lennie (8/26/2010)
One of the help name is pussycat59.
Nope, it's happycat59.
If you look at the earlier responds you will notice it.
Make it your practice to view earlier posting inorder to understand the problem
Maybe it's not what you intended, but that came out sounded condescending and borderline rude. I did review the entire thread before posting, several times.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 26, 2010 at 4:38 pm
I made typo error it should be happycat59 and not pussycat59.
Because the name is happycat59 which that cat in my house is a happy cat so I called is pussycat.
August 26, 2010 at 4:41 pm
since there are name like HappyCat, I will eventually change my login name a YummyRat
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply