I recently found an issue whereby I wanted to use the sp_MSforeachtable stored proc to select all tables with the word Transcode in the table name, and to run some SQL on those tables. I managed to write some code which worked, but not perfectly – for those tables which I’d hoped it would graceful…
Tag: sql
CREATE TYPE on MySQL
I couln’t create a new data type on MySQL. Query is given below How can I do that on MySQL Answer You cannot. MySQL doesn’t have user-defined types. (At least, not in current versions.)
SQL Server: Cannot insert an explicit value into a timestamp column
When using this statement I get the following error: Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column How do I insert the current time to a timestamp column? Answer According to MSDN, timestamp…
script issue Transact-SQL
I Want to return All table names from a use data base but this just return a char the output is s s s s s s Answer You need to define the length of @tableName, by default it is set to 1 character.
SQL Server Convert Varchar to Datetime
I have this date format: 2011-09-28 18:01:00 (in varchar), and I want to convert it to datetime changing to this format 28-09-2011 18:01:00. How can I do it? Answer
How to create a sql view (CREATE VIEW) in sqlite(android) and query?
So I have a table and I want to create another table using “CREATE VIEW” from sql. I need to make a copy of the table that I am working with so I can use it 2x. My sql query would have to be like this: my initial table is: so anyone has any ideea where (in my code) I
How to sum Accounts
I have 3 tables: DimAccounts, DimTime and FactBudget. DimAccounts example: DimTime example: FactBudget example: In FactBudget are many Accounts just with type B. I need to calculate Debit and Credit Sums where Account type is S (Sum). Columns AccountFrom and AccountTo shows B Type Accounts from where to begin…
Stored Procedures vs Code in Database Query
What are the performance differences between accessing a database to query using ASP.NET Code behind against using SQL Stored Procedure For ease of use, coding the query is easier, especially when …
How to retrieve the current value of an oracle sequence without increment it?
Is there an SQL instruction to retrieve the value of a sequence that does not increment it. Thanks. EDIT AND CONCLUSION As stated by Justin Cave It’s not useful to try to “save” sequence number so is good enough to check a sequence value. I still keep Ollie answer as the good one because it …
Use one CTE many times
I have this, and i get an error at set total. Why can’t i access a cte many times? ALTER PROCEDURE [dbo].[GetLeaguePlayers] ( @idleague int, @pageNumber int, @pageSize int, @total int …