Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

I'm totally new. Need some guide on SQL 2012 Expand / Collapse
Author
Message
Posted Wednesday, July 30, 2014 9:26 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, September 6, 2014 3:20 AM
Points: 10, Visits: 61
So many great advice on this thread.. At the moment I am going through the CBT Nuggets videos for 70-461.. I am on the third video about creating and altering table views, and I got stuck running a sampledata.sql to be inserted into my tables.. I'll add an attachment. Maybe you guys know what the problem here is.. It's holding me back from continuing my video-lessons :)

It's on the sales and employee rows.. The product part runs just fine


  Post Attachments 
Capture1.PNG (29 views, 30.99 KB)
Post #1597813
Posted Wednesday, July 30, 2014 10:07 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, October 28, 2014 6:59 AM
Points: 39, Visits: 280
Good that you put error message.
I can not access to CBTNuggest at this time, but you can check table structure by right click on the table-->Script table as--> create to --> XXXX and see whether the structure is different.
Example Sales, it should look like.
CREATE TABLE [dbo].[Sales](
[ID] [uniqueidentifier] NULL,
[Num1] [smallint] NULL,
[Num2] [smallint] NULL,
[Num3] [smallint] NULL,
[DateAdd] [datetime2](7) NULL
) ON [PRIMARY]

If you still have the issue, posted your tables structure here.

It may be lot of reason, this may be one of them.

Just my 2 cents.

Thanks

JJ
Post #1597836
Posted Wednesday, July 30, 2014 10:38 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 4:21 PM
Points: 3,924, Visits: 8,915
And that's why it is considered best practice to include the column list of the destination table. Something like the following, but I don't know how the real structure of the table is.
INSERT INTO Products(
ProductID,
ProductName,
Price)
SELECT 1,
'Shirt',
12.99

EDIT:
You can use Object Explorer to make this task easier. Navigate to the table and use your mouse to drag the Columns folder of the table to the desired place in your code.



Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1597857
Posted Wednesday, July 30, 2014 12:21 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, September 6, 2014 3:20 AM
Points: 10, Visits: 61
hmmm.. ok, this is my structure afaik:
-------------------------------------
USE [NuggetDemoDB]
GO

/****** Object: Table [dbo].[Employees] Script Date: 30.07.2014 20:21:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Employees](
[EmployeeID] [int] NOT NULL,
[FirstName] [nvarchar](59) NOT NULL,
[MiddleName] [nvarchar](50) NULL,
[LastName] [nvarchar](75) NOT NULL,
[Title] [nvarchar](100) NULL,
[HireDate] [datetime] NOT NULL,
[VacationHours] [smallint] NOT NULL,
[Salary] [decimal](19, 4) NOT NULL,
[ActiveFlag] [bit] NOT NULL,
[ModifiedDate] [datetime] NOT NULL,
PRIMARY KEY CLUSTERED
(
[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
Post #1597895
Posted Wednesday, July 30, 2014 12:47 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 4:21 PM
Points: 3,924, Visits: 8,915
You're missing the last 2 columns in your insert statement. You need to modify it to include those values.


Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1597913
Posted Thursday, July 31, 2014 11:54 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, September 6, 2014 3:20 AM
Points: 10, Visits: 61
Ahh ofcourse! Thanks! I thought that the query was smart enough to rule them out if they were not "mentioned". Thanks man!
Post #1598419
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse