I have an application that creates a Sql Server 2008 database. When I create the database, I would also like to create a datasource for SSRS.
How can I do this?
My database has about 30 views, most of which have a reference to another database on this server (call it DB1).
Now, without going into the reasons why, I need to update all those views to DB2, also on the local server.
I would hate to have to do this manually on each view. Is there some SQL query I can run that will replace all occurrences of the string 'DB1' with 'DB2' in all my views?
I'm querying a view and filtering the results with a column named status. I'd like to query it so I can search for rows with different status, by using the IN operator as I'd do in SQL.
As so:
SELECT * FROM VIEW WHERE Status in ('....', '.....')
How can I achieve this?
Hello!
To empty database table, I use this SQL Query:
TRUNCATE TABLE `books`
How to I Truncate table using Django models and orm?
I've tried this, but it doesn't work:
Book.objects.truncate()
Having a bit of difficulty figuring out how to create a named_scope from this SQL query:
select * from foo where id NOT IN (select foo_id from bar) AND foo.category = ? ORDER BY RAND() LIMIT 1;
Category should be variable to change.
What's the most efficient way the named_scope can be written for the problem above?
Hi,
I've got table Articles
ID identity autoincement, IDArticle: nvarchar(100) ,IDCar nvarchar(100), createddate
How to convert this:
SELECT IDCar , MAX(createddate)
FROM Articles
GROUP BY IDCar
to get IDArticle
eg:
1 art1 BWM 5-21-2010
2 art2 BMW 5-24-2010
3 art3 BMW 5-31-2010
4 art4 Porshe 5-31-2010
5 art5 Porshe 6-1-2010
Expecting result is:
art3
art5
It's not duplicated with:
http://stackoverflow.com/questions/2736769/sql-query-number-of-occurance/2736809#2736809
hi,
i have to create window service which read the xml file and and take the node's value to connect the sql server and create the log file i have already created window application for that but i don't know how to create win services.
Hi
I would like to create a temporary table in a Oracle database
something like
Declare table @table (int id)
In SQL server
And than populate it with a select statement
Is it possible?
Thanks
Here's the situation. I have a bunch of objects that implement Serializable that I want to store in a SQL database. I have two questions
Is there a way to serialize the object directly into the database
Is that the best way to do it or should I
Write the object out to a formatting String and put it in the database that way and then parse it back out
Write each member to the database with a field that is unique to each object
Hi,
I have the following table in an access database
id VisitNo Weight
1 1 100
1 2 95
1 3 96
1 4 94
1 5 93
Now row 2 and 4 are deleted. So i have...
id VisitNo Weight
1 1 100
1 3 96
1 5 93
However what i need is...
id VisitNo Weight
1 1 100
1 2 96
1 3 93
What is the SQL query i need to accomplish the above?
thanks
Assuming you can't use Linq for whatever reason, is it a better practice to place your queries in stored procedures, or is it just as good a practice to execute ad hoc queries against the database (say, Sql Server for argument's sake)?
We have a xml column in SQL Server 2008. We need to do reporting off the data in the xml so we're going to select the xml into a flat table. The flat table has columns that correspond to various nodes in the xml.
What is the best way to do this using SSIS?
Is this a good approach? Or should we just try and write the reports directly off the xml column?
i would like all data that is entered into a specific column to always have a trailing comma and also i need the first character to always be a comma. how do i do this? the best solution is probably not in vba or sql but probably the properties of the table?
An insert statement with a large number of values returns 'Error converting data type varchar to numeric.'
How can I find which value actually triggers the error?
MS SQL Server 2008 is used.
Somewhat new to SQL queries and I need a little help with my join.
I am supplied with gid
For each of these I need to grab name from table wp_ngg_gallery
then join in table wp_ngg_pictures and grab field filename limit 1 order DESC by field imagedate
Anyone able to help?
Good Morning,
Say I have an insert statement:
Insert INTO tblTest (fieldOne,FieldTwo,fieldThree) VALUES ('valueOne','valueTwo','null')
This statement doesn't seem to want to insert a null value into the database... I have also tried to insert the word "nothing".
Has anyone any ideas how to make this work? I am using SQL server 2005.
I have a java.sql.ResultSet object containg data from a query that was run.
How do I refresh the data in the ResultSet to reflect the current data in the database?
Thanks!
What is more efficient - handling with case statements in sql or handling the same data using if statements in code. I'm asking because my colleague has a huge query that has many case statements. I advised her to take stress off of the DB by coding the case statements. I've found that it is more efficient...but why?
Hello, I recently migrated from a PostgreSQL database to a SQL Server database. To switch the data over I had to enable IDENTITY_INSERT. Well come to find out that I get all sorts of strange errors due to duplicate identity values(which are set as primary keys) upon doing an insert in any of the tables.
I have quite a few tables. What would be the easiest way of automatically reseeding the identity of every table so that it is after max(RID)?
im using this sql query to create an index:
$query = "CREATE INDEX id_index2
ON countries(geoname_id, name)";
but how do i update the index when new entries are added?
should i run a php script with the update query in CRON and run it every night?
is this best practice for automated index updating?
How to connect to a database (any natively supported by .NET) - SQL Server 2008 or Access - from a Windows Forms application written on VC++/CLI (compiler ver. 16.0 from .NET 4.0)
Query:
Select * from pu_Products where Part_Number in ('031832','027861', '028020', '033378') and User_Id = 50 and Is_Deleted = 0
The above mentioned query is in SQL and i need the query might be converted into Linq. Is there any option using the "IN" operator in Linq?. can you convert above mentioned query into Linq?
Hi,
this SQL clause is working OK:
SELECT * FROM `sf_guard_user` WHERE nombre_apellidos LIKE REPLACE('Mar Sanz',' ','%')
Now I'm trying to write this query for Doctrine. I have tried this:
$query->andWhere(sprintf('%s.%s LIKE REPLACE (?," ","%")',
$query->getRootAlias(), $fieldName),
'Mar Sanz'));
but I get this error:
Warning: sprintf() [function.sprintf]: Too few arguments
Any idea?
Regards
Javi