I want to add users to the same role in more than one database. However the role may or may not be present in each database. How can I check if the role exists in each database and if it does, add users to that role? e.g. IF role exists BEGIN Add user in role END Answer try:
SQL method to replace repeating blanks with single blanks
Is there a more elegant way of doing this. I want to replace repeating blanks with single blanks…. (its sql server 2000 – but I would prefer generic SQL) Answer Here is a simple set based way that will collapse multiple spaces into a single space by applying three replaces. Your Update statement can now be set based: Use an
SQLite equivalent of PostgreSQL’s GREATEST function
PostgreSQL has a useful function called GREATEST. It returns the largest value of those passed to it as documented here. Is there any equivalent in SQLite? As a note, I only need it to work with 2 …
Could not find stored procedure ‘dbo.aspnet_CheckSchemaVersion’
I am using WinHost.com to host my site. The SQL Database/membership system works perfectly on my local computer, but when uploaded to the server it doesn’t work. I’ve followed all steps correctly. And …
generate days from date range
I would like to run a query like select … as days where `date` is between ‘2010-01-20’ and ‘2010-01-24’ And return data like: days ———- 2010-01-20 2010-01-21 2010-01-22 2010-01-23 2010-01-…
Inner Join two tables when one column is a text and the other is number
I have a program in access that is using some linked ODBC tables. I had originally had a query that contained the following INNER JOIN: This worked just fine until the column Neptune_prem.premice_id got changed from a number to a text data type. So now I need a way to use an INNER JOIN on two columns when one is
How to verify if two tables have exactly the same data?
Basically, we have one table (original table) and it is backed up into another table (backup table); thus the two tables have exactly the same schema. In the beginning, both tables (original table and backup table) contains exactly the same set of data. After some time for some reason, I need to verify whether dataset in the original table has
Finding duplicate rows in SQL Server
I have a SQL Server database of organizations, and there are many duplicate rows. I want to run a select statement to grab all of these and the amount of dupes, but also return the ids that are associated with each organization. A statement like: Will return something like But I’d also like to grab the IDs of them. Is
How to create a summary view from multiple views?
Given I have the following view where N=1..100 Currently we have summary views which insert to a table like The table is then used to create an overall summary like Is there a way to create summary_view_all_plants without having to create each individual summary_view_N? I would like to be able to iterate though a list of reports and dynamically generate
Oracle find a constraint
I have a constraint called users.SYS_C00381400. How do I find what that constraint is? Is there a way to query all constraints?