SQL Server - CROSS DEPENDENCIES DATABASES [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm able to pull cross databases dependencies but when the referencedDB is DIFFERENT DATABASE then I'm able to fetch the referenced object but not referenced OBJECT TYPE (e.g user_table,stored procedure etc..,)
Is there any way to find the OBJECT TYPE of referencedDB object?
Thanks in advance.

The system views (e.g., sys.object) are views, effectively under the schema sys.
So you should be able to get object types etc from statements like
SELECT type_desc
FROM yourOtherDatabaseName.sys.Objects
WHERE name = 'yourObjectToCheck'
Note - Information_schema is also similar - you can use them like
SELECT TOP 10 * from
yourOtherDatabaseName.INFORMATION_SCHEMA.tables

Related

How to you use Max and Min expression in Ms Access SQL? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
CrimeData Table for 12 months
Crime Took place in Easternmost
I need to find the following:
Q.7 What type of Crime takes place in the …
(a) Easternmost ………………..
(b) Westernmost ………………..
(c) Northernmost………………..
(d) Southernmost………………..
I tried to find the crime took place in the Easternmost using the following SQL code
SELECT Max(CrimeData.Easting) AS MaxOfEasting, CrimeData.Type
FROM CrimeData
GROUP BY CrimeData.Type;
but I got more than one crime and also other Easting numbers. Can you please tell me if there are other good ways to find the solution.
Please see the attached pictures :)
Rather than using Max/Min, have a look at the TOP keyword in SQL. Some SQL might look like:
SELECT TOP 1 CD.*
FROM CrimeData CD
ORDER BY CD.Easting DESC;
Regards,

How to rename column in Big Query? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
We are loading Datastore tables(i.e. kinds)(taken as backup in cloud storage) into Big Query manually. Is there any way to transform(rename etc.) datastore columns before being loaded to Big Query. It seems to support feature of E(extraction) and L(loading) but not T(transform) when datastore kind backups are loaded in Big Query.
The problem is that we have column-key as a primary field in our datastore kinds and hence we see column with name- "_key__.id" when kind loaded into Big Query.
We wanted this column to be loaded with name 'id' not "_key__.id". So just wondering, is there any way to rename the column in Big Query?
Timely help is hightly appreciated.
The "T" part of ETL is supported by means of SQL querying. You could either use directly query datastore backup as external table (https://cloud.google.com/bigquery/external-data-sources) or first load into temp table and then run SQL to transform it.
Renaming in Standard SQL will look like following:
SELECT * EXCEPT(oldname1, oldname2), oldname1 as newname1, oldname2 as newname2 FROM ...
But since you mentioned name separated by dot: _key__.id it is probably nested field with _key__ being of type RECORD, so the SQL will look like
SELECT * EXCEPT(_key__), _key__.id AS id FROM ...

i want to execute an sql query in ruby to use the result to make some tests in my views [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
this is the query :
SELECT COUNT(*)
FROM public.member_roles , public.members , public.users
WHERE public.users.id = public.members.user_id AND public.members.id = public.member_roles.member_id AND public.member_roles.role_id = 4 ;
in my views if this query return 1 , a text area is ganna be disabled
in rails
ActiveRecord::Base.connection.execute(your_sql_here)
you can find more info on this question. Hope this help you.
this will return Mysql2::Result object (if you are using mysql db and mysql2 gem. I belive for PG also it give similar object. to fetch data from it. here is a docs for Mysql2::Result.

Wrong Number of Arguments Used With Function in Query Expression [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have an SQL in Access 2010 that was written by someone else that gives a Wrong Number of Arguments error when I try and run it. It's supposed to filter a report from a search page.
SELECT Activity.[ProjNo], Activity.[Code], Activity.[Type], Activity.[ProjNoStatus],
Activity.[Preliminary], Activity.[Planner], Activity.[Designer],
Activity.[Officer], Activity.[Manager], Activity.[Staff], Activity.[Analyst],
Activity.[Manager], Activity.[DeptHead], Activity.[ContractNumber],
Activity.[InfoOfficer],Activity.[ProjNoDesigner]
FROM Activity
WHERE Activity.ProjNo=Index.ProjNo AND (((IIf([Forms]![SearchForm]![txtCode]="",
"*",[Activity].[Code]=[Forms]![SearchForm]![txtCode]))<>False)
AND ((IIf([Forms]![SearchForm]![txtType]="","*",[Activity].[ Type]="",
"*", [Activity].[Type]=[Forms]![SearchForm]![txtType]))<>False) AND
((IIf([Forms]![SearchForm]![txtProjNoStatus]="","*",
[Activity].[ProjNoStatus]<=[Forms]![SearchForm]![txtProjNoStatus]))<>False));
I'm not very experienced with SQL and, like I said, I didn't write this code (the person who did has long since retired) so any help would be great.
That query defines just one data source (table or query):
FROM Activity
But then the WHERE clause appears to reference another data source named Index:
WHERE Activity.ProjNo=Index.ProjNo
Since Index is not included in the FROM clause, Access will object when you try to use it in the WHERE clause.
However, I'm not sure that is the cause of the first error Access complains about. It may help to show us the full text of that error message.

Is there a way to remove specific characters from SQL Server Column [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a database table that contains a column for pricing.
Its very old, so it was written before i understood datatypes. so we are using varchar for a money value.
Ive noticed some columns have $ in them, so what I'm wondering is... is there a way with SQL Server to perform an update of the table and remove any instances of non numeric characters or at the very least remove the $ from the string in the columns in one go ?
I hope this is possible.
Update tbl
SET price = replace(price, '$', '')
Here is the replace definition