I have the following code:
USE pricingdb
go
CREATE TABLE dbo.Events_060107_2012
(
Date_Time varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
Event_Type TEXT,
Month_of_Year TEXT,
Survey DOUBLE,
Actual DOUBLE,
Prior_Data DOUBLE,
Revised DOUBLE,
Relevance FLOAT,
Ticker TEXT
);
Go
And I'm getting an Error:
"Incorrect syntax near ','. Level 15, State 1, Line 6"
I'm aware that this should be a pretty easy problem to fix, but for whatever reason I'm having a lot of trouble understanding how to go about fixing this. My knowledge of SQL is beginner at best, so most of the other threads I read were a little above my head.
Thanks in advance for any help.
Variables in SQL procedures are defined by using the DECLARE statement. Values can be assigned to variables using the SET statement or the SELECT INTO statement or as a default value when the variable is declared. Literals, expressions, the result of a query, and special register values can be assigned to variables.
If we want to declare a table variable, we have to start the DECLARE statement which is similar to local variables. The name of the local variable must start with at(@) sign. The TABLE keyword specifies that this variable is a table variable.
Firstly, if we want to use a variable in SQL Server, we have to declare it. The DECLARE statement is used to declare a variable in SQL Server. In the second step, we have to specify the name of the variable. Local variable names have to start with an at (@) sign because this rule is a syntax necessity.
DOUBLE is not a valid datatype in sql server
Use float, numeric, ... or any of the other types that are supported.
More info at http://msdn.microsoft.com/en-us/library/ms187752.aspx
Two issues. The first is that there is no datatype of double. The second is that float takes a size to indicate the difference in precision. An equivalent create query to the one above is:
CREATE TABLE dbo.Events_060107_2012
(
Date_Time varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
Event_Type TEXT,
Month_of_Year TEXT,
Survey FLOAT(53),
Actual FLOAT(53),
Prior_Data FLOAT(53),
Revised FLOAT(53),
Relevance FLOAT(24),
Ticker TEXT
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With