I'm reading a book about SQL.
In that book, I saw strange query below:
"SELECT * into mycustomer from customer WHERE 1=2"
In this query, what is "WHERE 1=2" ?
Thanks in advance.
hi
i have sql-server 2008 database that in the main server.
i have 10 terminals that connect to this server and work against the database.
i need that every new inserting to database through any terminal - in the server this
line will inserting to text file (every line)
can i do it ?
thank's in advance
I am using C#, Entity Framework and SQL Server 2008 Express.
I am connected to the database over internet.
What is the best method to speed up saving/updating data to database?
It takes 60 seconds to save 140 records to database.
I'm trying to use a dynamically generated fully-qualified table name in sql server 2008. For example, this does not work:
select max([id]) from @dbName+N'.[T1]'
This will give an error like:
Msg 102, Level 15, State 1, Line 73
Incorrect syntax near '+'.
I know that something like this works:
declare @qualifiedTable varchar(200) = @dbName+N'.[T1]'
select max([id]) from @qualifiedTable
But I have to do this LOTS of times so I would really like to do it in line. Is it possible?
I have been asked in an interview, To write a sql query which fetches the first three records with highest value on some column from a table. i had written a query which fetched all the records with highest value, but didnt get how exactly i can get only first three records of those.
could you help me in this.
thanks.
I am wondering how to create or export CSV file from SQL? Is tehre any function for that similar as pgsql2shp?????
I would appreciate your ideas, tip or solutions.
I get the following error in the query below:
#1064 - You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ')))' at line 1
Code Snippet:
INSERT INTO test_bans( ip, Expiration )
VALUES (
"0.0.0.0", DateAdd(
"d", 1, Date( )
)
)
Table creation query
CREATE TABLE test_bans (
ID smallint(6) NOT NULL AUTO_INCREMENT,
IP text NOT NULL,
Expiration DATETIME NOT NULL,
PRIMARY KEY (ID)
) TYPE=MyISAM;
What am I missing?
i am passing values from a textbox into a sql statement in ACCESS
i do not understand the difference in the usage of these two properties
when i set the the .text property to something, how does the .value property get affected?
when i do want something to be displayed in the textbox should i be using the value or text property?
Hi i'm trying to manipulate the sql connection string so instead of running the original copy of our database it runs from the copy one folder up in our C# project.
I want to execute query in side the db.sql file using MySQL 5.1 in windows environment. Can any one help me to this. I want to do this by runing a bat file.
I am trying to use open query to run a stored procedure in a remote database, and insert it into a table in my local database:
-- this works
exec remotesvr.sys.dbo.golden_table 'some', 'parameters'
While the above works out, I try the following:
insert into my_local_table
exec remotesvr.sys.dbo.golden_table 'some', 'parameters'
I get a SQL error to the effect of 'unable to begin a distributed transaction'.
Is there any way around this?, i.e. can I execute take the results of a remote stored procedure and put its contents in a local table?
I am using c# with asp.net and SQL Server 2005 as backend. I want to use dropdown list control in a form to populate a textbox. The dropdown control is linked to a column in the database. How can I code this in c#?
I have table "PICKITEM"
PARTID QTY
A 1
A 3
B 11
C 8
D 5
D 3
I need a select statement that will return one line for like PARTIDs and add the qty field to together, yet also return the rest of the lines in the table as is
PARTID QTY
A 4
B 11
C 8
D 8
Probably a newb question, but I am new to SQL syntax and queries. Any help in getting me on the right path would be appreciated!
I have a MySQL table with a column called "priority". The column can have two values: high or low. I want to select 8 records from the table at random, but I want 6 of them to be high priority, and 2 of them to be low priority. If possibly, I would like to do it in one SQL statement. Is there any way to do two LIMITS in one query based on this kind of criteria?
Not quite sure what I'm missing, but my SQL statement is only returning one row.
SELECT
tl.*,
(tl.topic_total_rating/tl.topic_rates) as topic_rating,
COUNT(pl.post_id) - 1 as reply_count,
MIN(pl.post_time) AS topic_time,
MAX(pl.post_time) AS topic_bump
FROM topic_list tl
JOIN post_list pl
ON tl.topic_id=pl.post_parent
WHERE
tl.topic_board_link = %i
AND topic_hidden != 1
ORDER BY %s
I have two tables (post_list and topic_list), and post_list's post_parent links to a topic_list's topic_id.
Instead of returning all the topics (where their board's topic_board_link is n), it only returns one topic.
Hi I want to know how to take a backup of database using programatically in VB.net of SQL Server 2005. if you are having and idea about it then pls send me the code for that.
Say I have these tables:
people(id, name),
cars(person_id, car)
and this query:
SELECT c.car
FROM people as p, cars as c
WHERE c.person_id = p.id
AND p.id = 3
I want the c.car column to take its name from the name field in the people table, like this (invalid SQL, just to illustrate):
SELECT c.car AS(SELECT name FROM people WHERE id = 3)
How do I do that?
Hi,
I have the following table:
bar_id, bar_name, subscription_id_fk, sub_name
eg:
1, Hard Rock, 2, Gold
2, TGIF, 1, Free
Now I need and SQL to extract this table, but where sub_name = Gold, I need to double the subscription_id_fk.
Can you please help
?
VB6 & SQL Server 2005
When i run the Windows based Software exe file,
it is showing the login page,
after login page - no screen is displaying,
I checked the task manager, in task manager it is showing as software as running,
But there is no page is appearing.
Is any firewall blocking or some other issue. But software is running with out displaying anythings.
How to solve this issue?
OK, see the numbers? I can barely see them because my Visual Studio 2010 theme has the backround as almost-black, and the numbers show up in the default color, which is black. I can't figure out which setting changes the color for a number in a .sql file. Does anyone know?
I have a asp:GridView with a HyperLinkField. It's DataNavigateUrlFormatString property is set to View.aspx?id={0}&isTechnical={1}
Select command of appropriate SqlDataSource returns columns of type INT and BIT (from SQL Server 2008).
So displayed string becomes something like View.aspx?id=1&isTechnical=1. But I want to display isTechnical=true|False, i.e. Convert.ToBoolean(row["isTechnical"]).ToString().ToLowerInvariant().
How to implement such conversion in page markup?
Hi,
I converted an old sql server database from 2000 to 2005 and forgetten to add old indexes to the new db.
is there any way to copy the old indexes to the new db?
any help?
i have oracle background,
i am looking for oracle v$sql view in mysql in order to see last queries has been run on all sessions in database
how can i see this in mysql ?
I need to get all rows tha are valid, ValidDate is column that shows how long these database items are valid. I need to get only valid items from the database. How can I do that? I use SQL Server.
Please, could you answer my question.
How to remove digits from the end of the string using SQL?
For example, the string '2Ga4la2009' must be converted to 2Ga4la. The problem is that we can't trim them because we don't know how many digits are in the end of the string.
Best regards, Galina.