SQL does replace and CAST on select affect the Database? [closed] - sql

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am creating a view and I was asked to do a 'replace' and a 'cast', so as an example:
SELECT CAST(qtyshipped AS INT) AS 'QTYShipped', REPLACE(itemval,'.','')
FROM Database
Within the view, should not actually change the information in the database but just in the query correct? (It works perfectly in my sandbox server but i just want to confirm)

Not a dumb question at all. And the answer is yes, it only changes the result of the query, the underlying data will remain the same.

That is already a good query. But I need to tell some points with you.
REPLACE function is case-sensitive. Although I've seen in your code that you are only replacing period.
Why is your column qtyshipped is not in numeric type? You should have change that into numeric. So you won't need casting which may lower the performance.
It will not affect your database since your are only executing SELECT not UPDATE.

Related

Looking for a collection of data with no clear pattern [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am trying to run a query to search for a collection of data with no clear pattern, in fact it conflicts with an existing pattern.
The solution I have in mind is to run the query with an AND for all the data that does have a pattern(let's assume every other record follows pattern, except for what i am looking for, so it's basically scattered with no clear way of putting it together) and them what's left over, can be retrieved and displayed.
The solution I have in mind is to run the query with an AND for all
the data that does have a pattern
Well, if you want to find everything that doesn't follow any pattern just enclose all the patterns within brackets and combine with boolean AND.
Then just put a NOT outside the brackets.
Example:
select * from data where
NOT (CONDITION1 AND CONDITION2 AND...AND CONDITION_N)
I imagine your conditions are statements such as string comparisons using like (and wildcards) in addition to arithmetic comparisons.

My database's table cleaning itself (SQL Server 2008 Express) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I got an epic problem about my datas that in my tables. I insert some data into a table and I wait 5 or 10 mins and table clears itself. I don't know why. My application doesn't have a code bug, but I think SQL Server has a bug. PLease help...
My best guess is that your code creates the database or the table each time it runs, thus seemingly deleting the data inserted.
Make sure you commit your changes. It is my guess that the tool you are using is not committing your changes automatically because of its settings.

RoR - How To Count & Display Comments [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm looking to have a count of the number of comments left under an article and display it on the index page beside that particular article - like the example here in red circles. Any suggestions as to how I might do this?
The picture is an example of what I'm trying to do, its not my site.
This sounds like a good candidate for Rails.cache. Every time you create a new comment simply increment that cache counter using the post id.
If the cache entry does not exist, do a simple article.comments.count (depends on your domain model of course) query and re-cache it.
Storing it in a cache is one idea, yes.
But storing it in a counter_cache column is probably a better idea. That way even if your server was restarted somehow you wouldn't loose the cached values. See http://guides.rubyonrails.org/association_basics.html, section 4.1.2.4.

How to make a view in SQL Server? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have more tables and I want to merge that some table for getting result.....
How can I do?
Views is just some sort of "stored query". It can be defined as:
CREATE VIEW viewname AS SELECT <the rest of select query here>
More details at msdn:
http://msdn.microsoft.com/en-us/library/ms187956.aspx
http://msdn.microsoft.com/en-us/library/aa214068(SQL.80).aspx
CEATE VIEW.
The rest of teh syntax is in ..... the documentation.
And this question is neither related to C# nor C++. It also does not care what you ate for breakfast. SQL works with strings the server interprets, and the langauge has no matter how the server does that.

What bit stand for in sql? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
when i take a data type as bit and when i insert 0 or 1 in that columns of the table then it give error. so please tell me how to remove the error?
Your question is missing a lot of required details.
If this is Microsoft SQL Server and you are entering them through the Table Editor in SSMS you need to type "True" or "False"
Bit means boolean, as the other two responders have said.
However, boolean values can be displayed in various ways. 1 and 0, true and false, 'Yes' and 'No' are examples. Try each of these, and if you're still not getting anywhere, let us know!
Good luck.