Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help with SQL

Author  Topic 

Harryt123
Starting Member

1 Post

Posted - 2006-11-07 : 20:22:17
I am new to SQL and have had no experience with it whatsoever. I am using Microsoft SQL server 2005 express. What I have to do is create an SQL server database to include customer information and then put the correct information into it's catagory on the table. To the best of my ability I have tried figuring out how to create the columns but now here is the problem that I am having. 1) Is that I get an error when I try to execute the code that I do have in the Query Window it gives me the following error "Msg 102, Level 15, State 1, Line 17
Incorrect syntax near '<'." and the 2nd problem is that all of the fields in which the information needs to be put in is "NULL." So I am not sure if I can manually insert the information but from trying that it didn't let me. I am going to post what I have of the code so far and if anyone can look at it and give any fixes or advice to this SQL Newbie I would be greatly appreciative.

INSERT INTO [Kudler Fine Foods].[dbo].[Employees]
([EmployeeID]
,[Last_name]
,[First_name]
,[Address]
,[City]
,[State]
,[Telephone_area_code]
,[Telephone_number]
,[EEO-1 Classification]
,[Hire_date]
,[Salary]
,[Gender]
,[Race]
,[Age])
VALUES
<EmployeeID, nchar(10),>
,<Last_name, varchar(50),>
,<First_name, varchar,>
,<Address, nchar(10),>
,<City, nchar(10),>
,<State, nchar(10),>
,<Telephone_area_code, smallint,>
,<Telephone_number, smallint,>
,<EEO-1 Classification, nchar(10),>
,<Hire_date, smalldatetime,>
,<Salary, money,>
,<Gender, nchar(10),>
,<Race, nchar(10),>
,<Age, numeric,>)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-08 : 00:11:05
You have to decide from where you want to insert the new customer.
Client side or QA?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2006-11-08 : 02:03:54
Kudler Fine Foods is a plagorised homework project... but in the intrest of higher science...
Since you are in the Kudler world you need to generate the script of the table Employees from the Kudler database. This is easily done from enterpise manager. But this too takes some learning, sorry, that's the way it goes. The general approach to that portion of the problem would be to 'Google' -> Tasks "Generate SQL SCRIPTS"

Then once you see a create table statement.

similar to this

CREATE TABLE
(
EmployeeID IDENTY (1,1),
[Last_name] VARCHAR(255) NOT NULL,
[First Name] VARCHAR(255) NOT NULL,
.....
)

you will have gained an insight into what the INSERT
command requires of "YOU" (oh my god the pressure)

So from the CREATE TABLE statement you can identify each attribute as having to have a meaningful or not NULL value. If the Table definition describes the column as NULL the person who define the table has evaluated that attribute of the future reality as NOT knowable in some conditions, or of no consequence or simply unknowable rather than meaningless.

notice we are agnostic here....

NOT is not the same as meaningless OR "". NOT as it relates to NULL is undefined....clueless..... belonging to the ether.....no politics.

So you can then defined which of the values in your INSERT statement which you posted require values even meaningless values like empty stings ("") OR true NULLS (which aren't meaningless, they are truely unknowable)
If a column in the Create Table statement is followed by NOT NULL you must include a value. if it is NULL then you have options (there are other conditions more complex than to mention here)

If they are not required (column NULL) you can REMOVE them from the insert statement in the first part AND the VALUES section OR maintian them in both parts AND declare the corresponding VALUES information as NULL 'John','Doe',NULL,'Chicago','IL',NULL,.......

I will help you further but please realize that at this moment in time, If you chose to think about what has been answered here and persure your understanding of it, it will change your life. If you include the Create Table definition related to this post you will probably get a specific answer ideally suited to solve your problem, will have learned how to do a deed but have learned nothing other than how to better ask a question, and will ask the same question in a different form in the new future, but may be generally happy. Generally happy suits most folks, there is however the opportunity to do more than that. Choose.




"it's definitely useless and maybe harmful".
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-08 : 02:10:08
INSERT INTO [Kudler Fine Foods].[dbo].[Employees]
([EmployeeID]
,[Last_name]
,[First_name]
,[Address]
,[City]
,[State]
,[Telephone_area_code]
,[Telephone_number]
,[EEO-1 Classification]
,[Hire_date]
,[Salary]
,[Gender]
,[Race]
,[Age])
VALUES (
'Peso'
,'Larsson'
,'Peter'
,'somewhere street'
,'helsingborg'
,'skåne'
,'0739'
,'149666'
,'Saint'
,'196x0906'
,3210.98
,'male'
,'formula 1'
,3x)

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-09 : 10:17:41
Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

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

DHale
Starting Member

4 Posts

Posted - 2008-10-23 : 14:10:39
Hi my first report work great thank to the help I got I made some chagest to the code and add some thing I get (Invalid column name 'amount'.) is amount use as a reserve word in SQL


IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[COA]') AND type in (N'U'))
DROP TABLE [dbo].[COA]

CREATE TABLE [dbo].[COA](
[coa_id] [int] NOT NULL,
[chart_of_account] [varchar](150) NOT NULL,
[account_desc] [varchar](100) NOT NULL,
[amount] [money] NOT NULL,
CONSTRAINT [PK_COA] PRIMARY KEY CLUSTERED
(
[coa_id] ASC
)
)

INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100001, 'Petty Cash ', 'Operating Cash - La Jolla', 88696.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100002, 'Petty Cash ', 'Operating Cash - Del Mar', 31430.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100003, 'Petty Cash ', 'Operating Cash - Encinitas', 17572.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100010, 'La Jolla Undeposited Receipts', 'Undeposited Receipts', 73672.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100011, 'Del Mar Undeposited Receipts', 'Undeposited Receipts', 23100.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100012, 'Encinitas Undeposited Receipts', 'Undeposited Receipts', 60535.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100020, 'Bradley Bank', 'Checking Accounting - La Jolla', 32426.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100021, 'Kelsey Bank', 'Checking Accounting- Del Mar', 27627.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100022, 'Downey Bank', 'Checking Accounting - Encinitas', 62056.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100030, 'La Jolla - Payroll', 'Bank Account', 5121.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100031, 'Del Mar - Payroll', 'Bank Account', 84674.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100032, 'Encinitas - Payroll', 'Bank Account', 12494.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100040, 'La Jolla - Workers'' Comp', 'Workers'' Compensation', 46267.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100041, 'Del Mar - Workers'' Comp', 'Workers'' Compensation', 29175.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (100042, 'Encinitas - Workers'' Comp', 'Worker''s Compensation', 57319.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (111000, 'Accounts Receivable', 'La Jolla', 74920.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (111001, 'Reserve for Bad Debts', 'La Jolla', 64311.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (112000, 'Accounts Receivable', 'Del Mar', 86118.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (112001, 'Reserve for Bad Debts', 'Del Mar', 13230.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (113000, 'Accounts Receivable', 'Encinitas', 58655.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (113001, 'Reserve for Bad Debts', 'Encinitas', 74834.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121000, 'Rustic Baguette', 'La Jolla Bakery Department Merchandise Inventory', 35564.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121001, 'Challah', 'La Jolla Bakery Department Merchandise Inventory', 39497.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121002, 'Calamata Olive Bread', 'La Jolla Bakery Department Merchandise Inventory', 77350.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121003, 'Ciabatta', 'La Jolla Bakery Department Merchandise Inventory', 37836.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121004, 'Ficelle', 'La Jolla Bakery Department Merchandise Inventory', 3486.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121005, 'Finnish Rye', 'La Jolla Bakery Department Merchandise Inventory', 36899.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121006, 'Prussian Rye', 'La Jolla Bakery Department Merchandise Inventory', 59364.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121007, 'Italian Semolina', 'La Jolla Bakery Department Merchandise Inventory', 28883.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121008, 'Sourdough Rounds and Batards', 'La Jolla Bakery Department Merchandise Inventory', 53083.00);
INSERT INTO COA (coa_id, chart_of_account, account_desc, amount) VALUES (121009, 'Swiss Muesli', 'La Jolla Bakery Department Merchandise Inventory', 13392.00);
Select * from COA
Go to Top of Page
   

- Advertisement -