Can a TABLE have a primary key without a clustered index? And can a TABLE have a clustered index without having a primary key? Can anybody briefly tell me the relationship between primary key and …
Tag: sql
Calling Functions in SqlCommand
Can I use Sql Server functions in myCommand.CommandText and why? Answer If you mean, SQL Server user defined functions. Then, yes; you can use it normally like: The reason it works is because this is the way that functions are called in SQL Server directly.
Getting a date from a form and saving into database and listing products
I’m trying to create a page which can list products which are saved in the database and then the customers can view the list of products that are available.The problem I am having is with the date in …
Select updated rows in mysql
Is there simple way to select updated rows? I’m trying to store timestamp each time I am read row to be able to delete data that was not readed for a long time. First I tried execute SELECT query first and even found little bit slow but simple solution like but I still want to find a normal way to
Is the LIKE operator case-sensitive with SQL Server?
In the documentation about the LIKE operator, nothing is told about the case-sensitivity of it. Is it? How to enable/disable it? I am querying varchar(n) columns, on an Microsoft SQL Server 2005 installation, if that matters. Answer It is not the operator that is case sensitive, it is the column itself. When …
Regex remove all occurrences of multiple characters in a string
In my PostgreSQL I want to replace all characters (;) occurrences in a string. My query: update table_name set text = regexp_replace(text, ‘/[(;)]+/g’, ”); I think my regexp is …
Bulk load: An unexpected end of file was encountered in the data file
I am using SQL Server Express 2008 When I’m trying load data from txt file in to this table create table Clients ( ClientID int not null IDENTITY (9000,1), LastName varchar (30)not null, FirsName …
Does Postgresql plpgsql/sql support short circuiting in the where clause?
If I have the following toy query Would the first condition in the WHERE clause short circuit the second condition which would have a complex run time? I’m working on some sql that is actually part of a FOR LOOP in plpgsql, and I could do iterations over all records that exist in the my_other_tables, an…
MYSQL, How to combine the first 2 letters of the first name and the first 5 letters of the last name
I’m trying to write an SQL query (using the SELECT function) that will take the first two letters of the first name and the first 5 letters of the last name, then combine them and put them in a new column called “User Name.” I’ve tried using the SUBSTRING and CONCAT functions together,…
How to SUM two fields within an SQL query
I need to get the total of two fields which are within the same row and input that number in a field at the end of that same row. This is my code. Is this what the SUM function is used for, or can you only use the SUM function for getting the total of a column? Thanks Answer SUM