Why did this SQL Server view stop working - sql

I have a rather long view thahas been working for years. After upgrading the server to SQL server 2014. I started getting a bind error: dboSubjects.Race" could not be bound.
The dboSubjects.Race is used like this in the view:
dbo.SUBJECTS.Race, dbo.SUBJECTS.Sex, dboSubjects.Race + dbo.SUBJECTS.Sex AS RaceSex,
If I remove the
dboSubjects.Race + dbo.SUBJECTS.Sex AS RaceSex
The view then functions. Can anyone explain how I can fix this problem and explain why it stopped working. I can only quess that the upgrade had something to do with it.
Thanks for your help
Perry

dboSubjects.Race + dbo.SUBJECTS.Sex AS RaceSex
You are missing a dot in the first part - should probably be dbo.Subjects.Race

Related

Query on INFORMATION_SCHEMA.JOBS_BY_PROJECT throwing dml_stats error

I have recently started seeing an error when i simply run
SELECT * FROM region-eu.INFORMATION_SCHEMA.JOBS_BY_PROJECT
Field name dml_stats does not exist in STRUCT<...
Excluding field dml_stats doesn't seem to work either.
Anyone else spotted this?
Cheers.
There are already 2 issues reported in the public issue tracker.
https://issuetracker.google.com/issues/193159258
https://issuetracker.google.com/issues/193437397
This seems to be a bug on the Google side. Hopefully, they will fix it soon.

NodeJS + Express "Error: -2006,\, Can not bind parameter(s)"

My company is working on converting from ColdFusion to NodeJS with Express, I'm running into an error trying to update some data in SQLAnywhere.
I have one update function working with 5 pieces of data. I'm working on my second, with 23 data points, but I'm running into an error stating:
"Error: Code: -2006 Msg: Can not bind parameter(s)."
I can't find any information about this online, not even using the error code. Any help, or pointing me in the right direction, would be appreciated.
Turns out it was trying to save integers into "char" fields on the database. Odd that we never had this issue with ColdFusion, but using "String(…)" around the values seemed to solve the issue.

FreeTDS ODBC error "The identifier that starts with ... is too long. Maximum length is 128."

I've been using pyodbc and free TDS to a submit queries to a microsoft SQL-2012 without issue for a while now but have recently stumbled on an issue.
When I submit a longer query I get an error message saying that one of the identifiers is too long and the script crashes.
The EXACT same query works in management studio and doesn't even return a warning.
I've added the following to my code with no avail.
SET QUOTED_IDENTIFIER OFF
SET ANSI_NULLS ON
The piece of code that the error is referring to is here:
(ZR_KOPF.ZRK_DDP_B IN ('190/TEMP.AA1H', '190/RAIN.AA1H', '190/WDR.AA1H', '190/WSP.AA1H', '190/SD1.AA1H', '190/HUMID.AA1H', '190/NO2.AA1H', '190/PM10.AA1H', '190/PM2.5.AA1H', '190/SO2.AA1H', '190/OZONE.AA1H', '190/CO.AA1H', '206/TEMP.AA1H', '206/RAIN.AA1H', '206/WDR.AA1H', '206/WSP.AA1H', '206/SD1.AA1H', '206/HUMID.AA1H', '206/NO2.AA1H', '206/PM10.AA1H', '206/PM2.5.AA1H', '206/SO2.AA1H', '206/OZONE.AA1H', '206/CO.AA1H')) AND ZR_KOPF.ZRK_BASEPRODUCTION = 1)
The error I get is:
pyodbc.ProgrammingError: ('42000', "[42000] [FreeTDS][SQL Server]The identifier that starts with ''190/TEMP.AA1H', '190/RAIN.AA1H', '190/WDR.AA1H', '190/WSP.AA1H', '190/SD1.AA1H', '190/HUMID.AA1H', '190/NO2.AA1H', '190/PM10.AA' is too long. Maximum length is 128. (103) (SQLExecDirectW)")
Pyodbc version: 4.0.18b1
freetds version: 1.00.48
Any help would be much appreciated
Cheers!
So turns out the spaces between each of the items in the list made all the difference...
I removed them and the query worked without a hitch.
Thanks for all the help everyone!

Sort by minute doesn't work

I'm trying to sort my photos by hour and minute but it will not catch the minutes - it's just keep saying that nothing exists for that hour and minute. If I'm trying to sort only after the hours, it works perfectly. I have tested WHERE DATEPART(minute, exif_taken) = "'.$_GET['min'].'" but I'm keep getting the following error message:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION gallery.DATEPART does not exist' in ...
I'm using WAMP Server with default settings except for some modules activated for both Apache and PHP like mod_rewrite and php_exif. Here's how my SQL query looks like:
SELECT *
FROM photos
WHERE HOUR(exif_taken) = "'.$_GET['h'].'"
AND MINUTE(exif_taken) = "'.$_GET['min'].'"
ORDER BY exif_taken DESC
$_GET['h'] is the hour and $_GET['min'] the minute.
How can I solve my problem?
Thanks in advance.
Are you using MySQL? If true, DATEPART() function doesn't exist. You shoul use MINUTE() function..
Here is the complete documentation.
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
BTW, for god sake, sanitize your _GET vars before send to the SQL query. You are exposing your system to SQL Injections.
In some odd way it's working perfectly now with the SQL query I posted in my question O.o

UKHost4U and MySQL - How to connect?

been waiting an hour to find out correct way to connect to mysql at UKHOST4U, thought someone on here may know?
Been using the following code, database, user & password are all setup correctly:
$hostn='localhost';
$dbn='cpanel1_dbname';
$passn='password';
$usern='cpanel1_usrname';
$dbh = #mysqli_connect($hostn, $usern, $passn, $dbn);
if(!$dbh)
die('hmm that did not seem to work; please try another day..');
I have obvioulsy changed the actual values.
I have just moved to UKHost4U - Am I missing something?!
I had to contact them and 'then it worked' as per normal..