Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


error in Micorsoft 70-432 book


error in Micorsoft 70-432 book

Author
Message
PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1428
I am doing some practice exercises from Microsofts training kit for 70-432 Implementation and Maintenance 2008(written by Mike Hotek) and am running the following code from page 148 (chapter 6 distributing and partitioning data) - i am however getting an error. The error is shown below. I am running this from sql2012 developer management studio.

use partitiontest

SET NOCOUNT ON
DECLARE @month int,
@day int

SET @month = 1
set @day = 1

while @month <= 12
BEGIN
WHILE @day <=28
begin
INSERT dbo.orders (OrderDate, OrderAmount)
SELECT cast(@month as varchar(2)) + '/' + cast(@day as varchar(2))
+ '/2005', @day = 20

SET @DAY = @DAY +1
END
set @day = 1
set @month = @month + 1
end
go


The error i get is:
Msg 141, Level 15, State 1, Line 0
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
Msg 199, Level 15, State 1, Line 0
An INSERT statement cannot contain a SELECT statement that assigns values to a variable.

Is this because i am using sql2012 instead of 2008 ? I find it hard to imagine that what appears to be a basic error (for somebody who has written a book !) would be allowed to be published !!
Ness
Ness
SSC Veteran
SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)

Group: General Forum Members
Points: 207 Visits: 974
PearlJammer1 (5/16/2013)
I am doing some practice exercises from Microsofts training kit for 70-432 Implementation and Maintenance 2008(written by Mike Hotek) and am running the following code from page 148 (chapter 6 distributing and partitioning data) - i am however getting an error. The error is shown below. I am running this from sql2012 developer management studio.

use partitiontest

SET NOCOUNT ON
DECLARE @month int,
@day int

SET @month = 1
set @day = 1

while @month <= 12
BEGIN
WHILE @day <=28
begin
INSERT dbo.orders (OrderDate, OrderAmount)
SELECT cast(@month as varchar(2)) + '/' + cast(@day as varchar(2))
+ '/2005', @day = 20

SET @DAY = @DAY +1
END
set @day = 1
set @month = @month + 1
end
go


The error i get is:
Msg 141, Level 15, State 1, Line 0
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
Msg 199, Level 15, State 1, Line 0
An INSERT statement cannot contain a SELECT statement that assigns values to a variable.

Is this because i am using sql2012 instead of 2008 ? I find it hard to imagine that what appears to be a basic error (for somebody who has written a book !) would be allowed to be published !!


Trust the error message - It's pointing you in the correct direction - Try SELECT cast(@month as varchar(2)) + '/' + cast(@day as varchar(2)) + '/2005', @day for the insert statement. You are trying to assign a value in the select stmt to the variable @day

SQL DBA
Every day is a school day, and don't trust anyone who tells you any different.
http://sqlblogness.blogspot.co.uk
Lynn Pettis
Lynn Pettis
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24285 Visits: 37993
PearlJammer1 (5/16/2013)
I am doing some practice exercises from Microsofts training kit for 70-432 Implementation and Maintenance 2008(written by Mike Hotek) and am running the following code from page 148 (chapter 6 distributing and partitioning data) - i am however getting an error. The error is shown below. I am running this from sql2012 developer management studio.

use partitiontest

SET NOCOUNT ON
DECLARE @month int,
@day int

SET @month = 1
set @day = 1

while @month <= 12
BEGIN
WHILE @day <=28
begin
INSERT dbo.orders (OrderDate, OrderAmount)
SELECT cast(@month as varchar(2)) + '/' + cast(@day as varchar(2))
+ '/2005', @day = 20

SET @DAY = @DAY +1
END
set @day = 1
set @month = @month + 1
end
go


The error i get is:
Msg 141, Level 15, State 1, Line 0
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
Msg 199, Level 15, State 1, Line 0
An INSERT statement cannot contain a SELECT statement that assigns values to a variable.

Is this because i am using sql2012 instead of 2008 ? I find it hard to imagine that what appears to be a basic error (for somebody who has written a book !) would be allowed to be published !!


Typesetting errors occur. The original manuscript may have the above code just fine. Could just be a QA error before publishing.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1428
Thanks - you where correct. I ommite the = 20 and it worked.
Thank you very much
:-)
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