I am trying to insert a row of data into a table in SQL Azure --
This is the insert statement--
INSERT INTO cloud_storage_credentials (cloud_provider,api_key, api_secret)
VALUES("Rackspace", "<random_value>", "<random_value>");
However I am getting the following error--
Msg 207, Level 16, State 1, Line 2
Invalid column name 'Rackspace'.
Msg 207, Level 16, State 1, Line 2
Invalid column name '<random_value>'.
Msg 207, Level 16, State 1, Line 2
Invalid column name '<random_value>'.
What am I doing wrong here? I followed an SQL Server tutorial to write the above query...
change the " (double quotes) to ' (tick/single quote)
INSERT INTO cloud_storage_credentials (cloud_provider,api_key, api_secret)
VALUES('Rackspace', '<random_value>', '<random_value>');
Change your "s with 's. As it is, it thinks that the values you are inserting are name of columns.
Related
I keep getting two error messages depending on what I try to do to fix them.
Firstly here is my code:
SELECT
ConsltNum AS 'Consultant Number',
COUNT(ConsltNum) AS 'Client Count',
AVG(Balance) AS 'Average'
FROM
Client Cl
INNER JOIN
Consultant Cn ON Cl.ConsltNum = Cn.ConsltNum
GROUP BY
Cn.LastName
Upon running it, I get this.
Msg 209, Level 16, State 1, Line 3
Ambiguous column name 'ConsltNum'.
Msg 209, Level 16, State 1, Line 3
Ambiguous column name 'ConsltNum'.
Now, I know it is ambiguous because the ConsltNum exists in both tables I've included. Normally I'd try and dial into that database by changing the code to this:
SELECT
Client.ConsltNum AS 'Consultant Number',
COUNT(Client.ConsltNum) AS 'Client Count',
AVG(Balance) AS 'Average'
FROM
Client Cl
INNER JOIN
Consultant Cn ON Cl.ConsltNum = Cn.ConsltNum
GROUP BY
Cn.LastName
Upon running this, I get:
Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "Client.ConsltNum" could not be bound.
Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "Client.ConsltNum" could not be bound.
A few other things worth mentioning: I've tried dialling to dbo.Client.ConsltNum and it throws the same error.
Just use the right alias:
SELECT cl.ConsltNum AS Consultant_Number,
COUNT(*) AS Client_Count, AVG(?.Balance) AS Average
FROM Client Cl INNER JOIN
Consultant Cn
ON Cl.ConsltNum = Cn.ConsltNum
GROUP BY cl.ConsltNum;
The ? is for the the alias of the table where balance comes from.
Notes:
You need to use the table alias assigned for the column.
The GROUP BY should match the SELECT column.
Only use single quotes for string and date constants. Give columns names that don't need to be escaped.
You might was well use COUNT(*), because you know ConsltNum is never NULL.
CREATE SECURITY POLICY Security_Policy
ADD FILTER PREDICATE RLS.fn_CanSeeSalary(EmployeeName)
ON dbo.Salary
WITH (STATE = ON);
When I execute the query above I get the following error:
Msg 343, Level 15, State 1, Line 37
Unknown object type 'SECURITY' used in a CREATE, DROP, or ALTER statement.
Msg 102, Level 15, State 1, Line 38
Incorrect syntax near 'FILTER'.
CREATE SECURITY POLICY Security_Policy
ADD FILTER PREDICATE RLS.fn_CanSeeSalary([EmployeeName])
ON dbo.Trn_AccDet
I have Table-valued function when trying to execute I am getting below error
Msg 208, Level 16, State 1, Procedure IPTRate, Line 19 Invalid object
name 'DBName.dbo.AccessTable'. Msg 4413, Level 16, State 1, Line 3
Could not use view or function 'dbo.ExchangeRate' because of binding
errors.
Actually the database name recently renamed from DBName to DBNameNew. Is the error because of database rename? how to fix this. please suggest.
Thanks.
Error message is clear..
Msg 208, Level 16, State 1, Procedure IPTRate, Line 19 Invalid object name 'DBName.dbo.AccessTable
you will need to rename all the views
I'm trying to create a database where the data and log files are saved to the E drive but not sure how to do so. I've tried:
CREATE DATABASE TachographDataContent_Archive
[ON E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data]
[LOG ON {D:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data}]
And I'm getting this error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'IF'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'TachographDataContent_Archive'.
To create database using query, you need to mention .mdf and .ldf file. So try below script.
Like this
CREATE DATABASE [TachographDataContent_Archive]
ON PRIMARY (NAME = 'TachographDataContent', FILENAME = 'E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data\TachographDataContent.mdf')
LOG ON
(NAME = 'TachographDataContent_log', FILENAME = 'E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data\TachographDataContent_log.ldf')
GO
good luck...
This is a table in a Microft Dynamics 2009 database. Our Test database is missing a bunch of Image data, so I would like to update the table in test with the data in production. I'm using this SQL for this update. When I execute this, I get this error:
Msg 8180, Level 16, State 1, Line 1
Statement(s) could not be prepared.
Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Query:
UPDATE INVENTTABLE
SET
Z_IMAGE = i2.Z_IMAGE,
Z_IMAGEMIMETYPE = i2.Z_IMAGEMIMETYPE
FROM INVENTTABLE i1
JOIN [PRODSQLSERVER].[DAX2009DB].[dbo].INVENTTABLE i2
ON i1.RECID = i2.RECID
WHERE i2.Z_IMAGE IS NOT NULL
I can't see a place where I'm attempting to compare or sort the Image data.
Try changing UPDATE INVENTTABLE to UPDATE i1.