digging a lot ... through SMMS, this query returns 44 table names that are present in the dbo schema
SELECT t.name
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
ON t.[schema_id] = s.[schema_id]
WHERE s.name = N'dbo';
this is true regardless of what database I hit (prod 1, prod2, dev 1, etc)
when I run that from rails c, i get
irb(main):006:0> results = Location.connection.exec_query("SELECT t.name FROM sys.tables AS t INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id] WHERE s.name = N'dbo'")
SQL (25.5ms) SELECT t.name FROM sys.tables AS t INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id] WHERE s.name = N'dbo'
=> #<ActiveRecord::Result:0x007fe390734800 @columns=["name"], @rows=[["spt_fallback_db"], ["spt_fallback_dev"], ["spt_fallback_usg"], ["spt_monitor"]], @hash_rows=nil, @column_types={}>
when pointing to the prod database where the query is failing. When I run it on the prod database where the Location query works, it sees all 44 tables as expected.
So, ultimately, i agree ... it is a perms issue.
gem install tiny_tds -v '2.1.1'
succeeds before bundling.hello guys, i have a question about the limit
method as i am having an issue with pagination.
the code records.page(1).limit(10)
gives this sql command: ... [users].[id] IN (1, 2, 3, 4, 9, 3, 5, 8, 10, 6)
notice that the ID = 3 is used twice.. resulting in incorrect pagination (returning 9 records instead of 10), any help is appreciated on how to fix this.
@KDGundermann I think the reason is the "includes" vs "left_joins".Device.left_joins(:health_records).order('health_records.error_number desc').page(1).limit(10).count
returns 10
Device.includes(:health_records).order('health_records.error_number desc').page(1).limit(10).count
returns 3
MyRecord.where(field_name: value).take
now fails with ActiveRecord::StatementInvalid
:TinyTds::Error: Invalid column name '"TicketNo", "UniqueID", "ItemNo"'.: EXEC sp_executesql N'SELECT [Tkscale].* FROM [Tkscale] WHERE [Tkscale].[TicketNo] = @0 ORDER BY [Tkscale].["TicketNo", "UniqueID", "ItemNo"] ASC OFFSET 0 ROWS FETCH NEXT @1 ROWS ONLY', N'@0 nvarchar(max), @1 int', @0 = N'10234770', @1 = 1
which is odd since I didn't ask for the ordering. I'm not sure how to fix this. I have set MyRecord.table_name = 'Tkbatch'
and MyRecord.primary_key = :UniqueId
. MyRecord.connection.schema_cache.primary_keys("Tkbatch")
returns ["TicketNo", "UniqueID", "ItemNo"]
. I can't find an issue or in the code where this should be addressed. any ideas?
order
but that's kind of a workaround
connect
is has the wrong username. There was an @server
automatically appended to it. I don't know if that is what the problem might be?
connect server name not found
error. I'm thinking this is just for connecting to a local sql server, and not one that is on a completely different machine. Can anyone point me in the right direction?
Perhaps I'm missing something, is there a way to define an Identity column that is not a primary key?
I am working with a legacy database which has some non-PK identity columns. When a performed a schema dump against our development database nothing seems to indicate that these columns are to be auto incremented.