I am messing around with one of my databases.. is there away for me to search for a string in ALL the tables.. and replace it with another everywhere it occurs?
I am looking for SQL
Hello,
I'm trying to build a facebook like search for my software.
I'd like to query the table customers.
I've set up a FULLTEXT Index and tried the next query
SELECT * FROM Customer where CONTAINS(*,'*ann*')
The query does return all the customers named Ann, but it doesn't return all the customers name Anne.
Is there a way to create prefix search on SQLSERVER 2008 using FTS?
Thanks.
In SQLserver,How can i place the value of more than one column in variables using one query
Ex : My query is :
SELECT ET.ID,ET.Description,ET.DefaultTemplateText
FROM TBL_EMAILTEMPLATE ET
WHERE ET.NAME='OneWeekReminder'
I want to place the Column values in variables.
Thanks in advance for the help
Hello all,
I have a table let's say in the form of: match(id, hometeam_id, awayteam_id) and team(id, name). How do I build my SQL query in order to get a result table in the form of (match_id, hometeam_name, awayteam_name), since they both (hometeam_id, awayteam_id) reference the same table (team)?
Thank you
I have this function I'm using and I want to be sure that it fully protects against SQL injection attacks:
function MakeSafeForQuery($string)
{
// replace all of the quote
// chars by their escape sequence
$ret = str_replace("\\","\\\\",$string);
$ret = str_replace("'","\\'",$ret);
$ret = str_replace("\"","\\\"",$ret);
return $ret;
}
Am I missing anything serious?
Hi I have a really complicated dynamic query
that i want to use to retrieve data from the database
I am working in .net 3.5 sqlserver 2008
i created a stored procedure that accepts a varchar(max) as input parameter and does
execute (@SqlQuery)
it executes but does not return anything
I really would like to use LINQ as all my project is implemented using linq
Any Idea how to do it
what is the problem?
Checking few RDBMS I find that things like
SELECT COUNT (a), SUM (b)
FROM TABLE
are allowed (notice space between aggregate functions and parenthesis).
Could anyone provide a pointer to SQL standard itself where this is defined (any version will do)?
Hi,
I'm thinking of developing the following but wondering if it already exists out there:
I need a SQL based solution for assigning and managing localization text values for an asp.net site instead of using RESX files. This helps maintain text on the site without having to take it down for deployment whenever an update is required.
Thanks.
I have two tables that I'm trying to create a relationship between so I can write nice LINQ queries that don't require join.
Widgets
WidgetId
WidgetDescription
Orders
OrderId
WidgetId
OrderDate
What I want to be able to do is create a LINQ query that does something similar to:
var result = from x in db.Widgets
Where x.Orders.OrderDate == "5/11/2010"
select x;
I can't seem to get intellitext to pick up the other database despite creating a relationship in SQLserver. Are there any additional steps I need to take to make this work?
Hi,
I have a tabel in an SqlServer 2005 database. I have the following column
IndPL INT DEFAULT 0 NULL
I want to change the column to be of the type NVARCHAR but I receive a constraint violation due to the fact that the column has a default value constraint attached to it.
I need to find out how to remove a default value constraint from a table column or how to change the column type without impeding the constraint.
Quick question playing with PL SQL it seems that the tables column was named as the data type NUMBER so trying to perform a query fails since the column is being recognized as a datatype instead of a column name. Anyone know how to get around this without modifying the schema?
Hello all.
I understand that I can change a sql table using the follow sp:
EXEC sp_rename 'customers', 'custs'
How would I go about appending this so that the new table has today's date as a suffix?
I've attempt variations on the below theme with little success!!
EXEC sp_rename 'customers', 'customers +(CONVERT(VARCHAR(8),GETDATE(),3))'
Any help greatly appreciated.
Hi all,
I have a rather large database that has alot of decimal columns in alot of tables, the customer has now changed their mind and wants all the numbers (decimals) to have a precision of 3 d.p. instead of the original two. Is there any quick way of going through all the tables in a database and changing any decimal column in that table to have 3.d.p instead of 2 d.p?
The db is on sql 2005.
Any help would be great.
Hi everybody,
Here it's my problem I've a list of the following measure :
src1 dst2 24th december 2009
src1 dst3 22th december 2009
src1 dst2 18th december 2009
I would like to have just the latest measures with a sql request - 2 first lines in my case because the pairs(src and dst) aren't the same.
I try to use DISTINCT but I have just the 2 first columns and I will all columns.
I try too GROUP BY but I hadn't success.
Anyone can help me ?
Thx
Narglix
I'm trying to select records with a statement
SELECT *
FROM A
WHERE
LEFT(B, 5) IN
(SELECT * FROM
(SELECT LEFT(A.B,5), COUNT(DISTINCT A.C) c_count
FROM A
GROUP BY LEFT(B,5)
) p1
WHERE p1.c_count = 1
)
AND C IN
(SELECT * FROM
(SELECT A.C , COUNT(DISTINCT LEFT(A.B,5)) b_count
FROM A
GROUP BY C
) p2
WHERE p2.b_count = 1)
which takes a long time to run ~15 sec.
Is there a better way of writing this SQL?
Hi
I have tried uploading a transparent PNG image to a SQLserver image field, and retrieving it using the DynamicData ImageHandler. The Transparent areas in the image appear white upon rendering. Please advise about any solutions
Cursor cursor = db.rawQuery("SELECT COUNT(rat)
FROM "+ TABLE_NAME_EXTRA +" apkid=\""+apkid, null);
cursor.moveToFirst();
int somatotal = cursor.getInt(0);
I'm trying to do a SQL function like count and sum, but this code returns a exception saying "emptyvalues".
anyone know why?
What's the best way to determine if a given SQLServer table is readonly, either because of account permissions or the database being marked as read-only?
I'm trying to execute a SELECT statement that includes a column of a static string value. I've done this in Access, but never with raw SQL. Is this possible?
Example:
Name Status
John Unpaid
Terry Unpaid
Joe Unpaid
In the above example, the "Status" column doesn't exist in the database.
Hi guys,
Basically I wanted to have an if-else statement in my linq to sql statement.
var query = from d in database
if(x == y) {
where d.Attr = x
}
else {
where d.Attr = y
}
select d;
Any ideas?
I have re-written my code after great help from some friendly stack overflow members (big thanks to Martin B and Kev Chadders especially). I would now like to check if my code is still open to SQL Injections after this work. I believe the code is now working as it should, but any blinding errors that you see i'd love to hear about too. My code is now looking like:
-code removed-