SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


I'm totally new. Need some guide on SQL 2012


I'm totally new. Need some guide on SQL 2012

Author
Message
kimmedim
kimmedim
SSC-Enthusiastic
SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)

Group: General Forum Members
Points: 110 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 Smile

It's on the sales and employee rows.. The product part runs just fine
Attachments
Capture1.PNG (37 views, 30.00 KB)
jarupan
jarupan
Old Hand
Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)

Group: General Forum Members
Points: 354 Visits: 398
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
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41764 Visits: 19815
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.
General Disclaimer:
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?


How to post data/code on a forum to get the best help: Option 1 / Option 2
kimmedim
kimmedim
SSC-Enthusiastic
SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)

Group: General Forum Members
Points: 110 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
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41764 Visits: 19815
You're missing the last 2 columns in your insert statement. You need to modify it to include those values.


Luis C.
General Disclaimer:
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?


How to post data/code on a forum to get the best help: Option 1 / Option 2
kimmedim
kimmedim
SSC-Enthusiastic
SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)

Group: General Forum Members
Points: 110 Visits: 61
Ahh ofcourse! Thanks! I thought that the query was smart enough to rule them out if they were not "mentioned". Thanks man!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search