SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Other Forums
 Other Topics
 Missing right parenthesis PLZ HELP :)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

fahim1234
Starting Member

Afghanistan
7 Posts

Posted - 01/05/2011 :  07:20:09  Show Profile  Reply with Quote

INSERT INTO LOCATION_DIM (SELECT COLUMN1 FROM SPREADSHEET3 WHERE LOCATION_ID = '409',
SELECT 'West Yorkshire' FROM COLUMN1 ,
SELECT 'Leeds' FROM COLUMN1 );

COULD U PLEASE HELP AND TELL WHY THIS CODE IS NOT WORKING...
I AM TRYING TO SELECT 3 THING FROM 1 COLUMN IN A TABLE

THANKS FOR UR HELP

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 01/05/2011 :  07:24:36  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
Please don't post in all caps. It's like shouting at us.

Please, please, please open up books online and look at the syntax and examples of Insert. It's clear you have no idea what the valid syntax is and guessing is not going to work.

As I said on your other insert thread, the valid forms of insert are
Insert into <table> (<Destination column list>)
Values (...)

and

Insert into <table> (<Destination column list>)
select <columns> from ...

You can't mix and match the two and expect it to work.

--
Gail Shaw
SQL Server MVP

Edited by - GilaMonster on 01/05/2011 08:00:43
Go to Top of Page

fahim1234
Starting Member

Afghanistan
7 Posts

Posted - 01/05/2011 :  07:51:02  Show Profile  Reply with Quote
thanks for your help , sorry wasnt shouting,
i am not using values anymore , im only using select statements... can you use more than 1 select statement in 1 insert statement to select from 1 column

tyutyu
Go to Top of Page

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 01/05/2011 :  07:56:12  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
You're still mixing the forms. Look at the two styles I described. Look where the brackets are.

Have you read through the syntax and examples on INSERT in books online? Books Online is the help file included with SQL. Press F1 in management studio to open Books Online.

Also look up the syntax for a select statement.
It's SELECT <columns> FROM <Table>, not SELECT <String values> FROM <Column>

Finally, I don't think you even need three selects. If I'm guessing correctly what you're trying to do, you need one select. Start by writing a single select statement that returns the data that you want to insert.

--
Gail Shaw
SQL Server MVP

Edited by - GilaMonster on 01/05/2011 07:58:43
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 01/05/2011 :  08:07:22  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Did you know that SELECT 'Leeds' FROM COLUMN1 will give the value 'Leeds' as many times as there are rows in the table?. Post some sample data from the table with expected result to be added to the table LOCATION_DIM

Madhivanan

Failing to plan is Planning to fail

Edited by - madhivanan on 01/05/2011 08:09:16
Go to Top of Page

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 01/05/2011 :  08:16:52  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
quote:
Originally posted by madhivanan

Did you know that SELECT 'Leeds' FROM COLUMN1 will give the value 'Leeds' as many times as there are rows in the table?.


More likely I think it will give
Msg 208, Level 16, State 1, Line 1
Invalid object name 'COLUMN1'.


Since n earlier select references Column1 as a column in table SPREADSHEET3

--
Gail Shaw
SQL Server MVP
Go to Top of Page

fahim1234
Starting Member

Afghanistan
7 Posts

Posted - 01/05/2011 :  08:51:14  Show Profile  Reply with Quote
thankew people your helping but its not help

tyutyu
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 01/05/2011 :  08:56:59  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by fahim1234

thankew people your helping but its not help

tyutyu


You need to give us more informations.

Do these give any errors?
SELECT 'West Yorkshire' FROM COLUMN1
SELECT 'Leeds' FROM COLUMN1

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

fahim1234
Starting Member

Afghanistan
7 Posts

Posted - 01/05/2011 :  09:10:31  Show Profile  Reply with Quote
EDIT LOCATION_ID COLUMN1 COLUMN2
409 Yorkshire & Humberside 12334
419 Richmondshire 123
420 Ryedale 89
421 Scarborough 5864
422 Selby 271
423 York 870
428 Sheffield "2,469"
429 West Yorkshire "17,483"
430 Bradford "4,075"
431 Calderdale "1,219"
432 Kirklees "2,589"
433 Leeds "7,391"

the spreasheet table looks a bit like this .. what i want is to select 'yorkshire & humberside', 'west yorkshire' and 'leeds' and put them 3 in a new table which is location_dim. im having trouble doing that ... could you please help and tell me how i can select those 3 data and put it in a new table please
Go to Top of Page

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 01/05/2011 :  09:13:01  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
I will repeat the advice I gave in an earlier post:

Start by writing a single select statement that returns the data that you want to insert. Can you do that?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 01/05/2011 :  09:46:09  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Start with this

SELECT COLUMN1 from spreasheet
WHERE COLUMN1 in ('yorkshire & humberside', 'west yorkshire' ,'leeds' )

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000