If I use _reverse_ wildcard search will it always result in a table
scan? Is it possible to get the DB (Oracle or SQL server) to use
indexes when doing reverse wildcard match?
HelloI am trying to search 2 columns on a databsae table using a string put into a box, the code i have at the moment is SqlConnection conn = new SqlConnection(SqlDSFindPost.ConnectionString); SqlCommand cmd = new SqlCommand ("SELECT * FROM tblBlog WHERE UserName LIKE @UserName OR Title LIKE @Title; ", conn); cmd.Parameters.Add("@UserName", SqlDbType.NVarChar, 50).Value = '%' + TextBox1.Text + '%'; cmd.Parameters.Add("@Title",SqlDbType.NVarChar, 50).Value = '%' + TextBox1.Text + '%'; conn.Open(); cmd.ExecuteNonQuery(); GridView1.DataBind(); I have tried all sorts of strings and even typeed the string directly into the parameter but never get any results, yet when i type the wildcards directly into the textbox i get the correct rows returned. Can anybody see anything wrong with my code and tell me where i am going wrong, or alternativly point me in the direction of some c# code for searching a database similar to the search box abovei dont do a lot in asp or c# so this is driving me crazy Thanks for looking
I have a need to use wildcards in a sql statement. e.g. select * from tbl where field='%computer%'. How can I substitute the string "computer" for a variable declared in the stored procedure. Procedure Sample @Str varchar(50) AS select * from tbl where field = '%' & @Str & '%' (How do incorporate the wildcard variable @Str?
I want to replace the NNNYYYYMMDDHHMM with a wildcard (for example *), so that import will pull ANY .SDF files in, but it will not run. i get the following:
output ------------------------------------------------------------------------------ DB-LIBRARY error: Bcp: Unable to open host data-file.
I need to replace the use of wild cards in my query with something else which achieves the same thing. The problem is the web application which uses the query does throws an error when using '%' characters. Any ideas?
The following statement appears in the where clause:
AccType.Value like '@Opened_By[%DIST%APP% as Distance and Business Provider, DIST% as Distance, APP% as Business Provider]'
Is there anyway I can return only the last row of a query, like TOP does for the top most items?I would like to return something like this:SELECT BOTTOM 1 Column_CFROM Table1WHERE Column_A = somethingAny help would be greatly appreciated. Thank you!
Does anyone know of a way to determine the code of a stored procedure that was built with encryption? I inherited a db with many of these and we are not sure which version of the source code exists on the server. Alternatively, can I compile a new SP and compare it to the old one in any way other than testing lots of data?
Is is possible to write a query that does the reverse of a cross tab query, I have a table that is mirrored for our Main frame, the table contains a item number a warehouse number and a date field and then 43 fields like field01 thru field43 which store quantities, each field out from 01 is another date our from the date field and I need to look for the item, warehouse and return a date where one of the many field is greater than or equal to the quantity I am looking for, I obviously will have to calculate the date field but thought If I could do the reverse of a cross tab giving a resuld set of 43 records for everyone in the first file I could do a quick update for item number, warehouse match and quantity field greater than what i need returning the date
blah blah blah , sorry I made it sound so confusing
I'm really sure it's not some complicated formula (because I managed to recover other fields) . I just want to reverse the formula used to "encrypt" this data. Thank you. Excuse my english.
I’m trying to use case statement in my view with wildcards for '%Tradies%', instead of listing all items
WHEN 'Tradies Rebate1' THEN 'Test' WHEN 'Tradies Rebate2' THEN 'Test' WHEN 'Tradies Rebate3' THEN 'Test' WHEN 'Tradies Rebate4' THEN 'Test'
At this moment '%Tradies%' does not work and gives me null values in EventGroup column.
Here’s my statemnt ------------------------------------------ CASE [dbo].[Event].[EventName] --WHEN 'Tradies Rebate1' THEN 'Test' --WHEN 'Tradies Rebate2' THEN 'Test' --WHEN 'Tradies Rebate3' THEN 'Test' --WHEN 'Tradies Rebate4' THEN 'Test' WHEN '%Tradies%' THEN 'Test' WHEN 'Install Products' THEN 'All Installed' WHEN 'Installation Product Conversion' THEN 'All Installed' WHEN 'Installation Products' THEN 'All Installed' WHEN 'BK 3' THEN 'All Bright Kids' END AS [EventGroup], ------------------------------------------
I have a SQL statement which is generated dynamically. I need to know what is the correct syntax for this
WHERE status = 'open' AND salesman = * AND dat = * AND customername = *
i.e. fetch everything WHERE status = 'open'
I know that simply WHERE status = 'open' would do the trick but I need it like the first example because of the way the statement is being generated i.e. this salesmen bit is like this.
If Salesman <> "*" Then sql2 &= " AND salesman = '" & Salesman & "'" Else sql2 &= " AND salesman = *" End If
Hi I'm using the full-text indexing on a table and I'm trying to implement a search where users can search for words and use wildcards themselves. However I'm working on a method so that can enter a wildcard in the middle of a word to get records where they are unsure of the spelling etc. For instance, a search of 'Ste*en' should return results like 'Steven' and 'Stephen' etc. So if they are searching for word 'establishment' they can search for 'estab*ment' and it should return all the records using this query: SELECT * FROM myTable WHERE CONTAINS(myField,'"estab*ment"') If I do a wildcard at the end e.g: SELECT * FROM myTable WHERE CONTAINS(myField,'"estab*"') I get the results I am looking for. But the middle wildcard does not seem to work as expected even though it is the syntax used on MSDN and other SQL info sites. Is there something I am not doing properly?
I have a stored procdure in SQL Sever that accepts paramteres. I am trying to return rows where parameter that is passed is somewhere in the cuustomer's name. Without the variable the SQL would look like this:
SELECT * FROM tbl WHERE CustomerName LIKE '%Smith%'
I can't figure out how to replace LIKE '%Smith%' with a varible. I tried '%@CustomerName%', ('%' + @CustomerName + '%') and neither works. Any ideas? Thanks
ps my column's type is char(50) and so is the variable so trailing spaces don't matter.
Hi all,I am creating an ASP.NET site, and I'm having lots of issues trying to get wildcards to work with the following query:DECLARE @Status varcharDECLARE @AssignedTo intDECLARE @AppID intSELECT dbo.Issue.IssueID, dbo.Issue.ReportedBy, dbo.Issue.ShortDescription, dbo.Issue.DateReported, dbo.Issue.Status, dbo.Priority.Description AS Priority, dbo.Application.ApplicationFROM dbo.Issue INNER JOIN dbo.Priority ON dbo.Issue.Priority = dbo.Priority.PriorityCode INNER JOIN dbo.Application ON dbo.Issue.Application = dbo.Application.ApplicationIDWHERE (dbo.Issue.Status LIKE '%' + @Status) AND (dbo.Issue.AssignedTo = @AssignedTo) AND (dbo.Application.ApplicationID LIKE '%' + @AppID)ORDER BY dbo.Priority.PriorityCode When running this through query analyser I get the error:Server: Msg 245, Level 16, State 1, Line 5Syntax error converting the varchar value '%' to a column of data type int. Could someone help me understand this please?Thanks
How do Iput wildcards around a number in an sp ? If my user leaves BoxNo blank it will list all boxes
SELECT * FROM tblFiles WHERE ConNo =@strRMUConsignmentNo and FileRef like '%'+@strtxtFileRef+'%' and Subject like '%'+@strtxtSubject+'%' and FileDescription like '%'+@strtxtDescription+'%' and BoxNo like %+@strBoxNo%
My use of wildcards thus far has been limited to matching a givenstring anywhere in a column as follows:SELECT * FROM Table WHERE Column LIKE '%string%'However, I'm wondering if there's a way to do this in reverse. Thatis, is there a way to match the column anywhere in the string?Pseudo-coding it as:SELECT * FROM Table WHERE 'string' LIKE %Column%What I'm trying to match is network addresses. Most of the storedaddresses in this table are exact (i.e. ip-1-2-3-4.location.isp.com)but sometimes they encompass an entire group (i.e. location.isp.com).When an exact address is given in the code I'm writing, it needs tomatch any rows that contain its exact self or contain a shortenedversion of which it is part.Any ideas?-cyber0nehttp://www.cyber0ne.com
please explain the differences btween this logical & phisicall operations that we can see therir graphical icons in execution plan tab in Management Studio
HI, I'm using Visual Web Developer and SQL Server 2005 Express Editions. I have a database with two tables, say AccountsTable and PersonsTable, with a one to many relationship respectively. Given a particular selected record in PersonsTable, I need to look up the corresponding master record in AccountsTable. Here's what I've done: SqlDataSource1 has a "SELECT * FROM PersonsTable" and a GridView1 which uses this as its datasource and the 'enable Selection' checkbox is On. This works fine. Then, I create a second SqlDataSource2. When I click on the WHERE button in the Configure Data Source page, I have chosen the following parameters: Column:PrimaryKeyField; Operator:=; Source=Control; ControlID=GridView1; Default Value='I left this blank' but the Value field shows GridView1.SelectedValue when I click the ADD button. <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:bizConnectionString %>" SelectCommand="SELECT * FROM [AccountsTable] WHERE ([AccountNumber] = @AccountNumber)"> <SelectParameters> <asp:ControlParameter ControlID="GridView1" Name="AccountNumber" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource>
I have bound DetailsView1 to SqlDataSource2. When I run the page, the GridView1 is shown with Persons records OK. Then I click the 'Select' next to a record in the Gridview expecting the corresponding lookup to the master record (Account) to be shown in the DetailsView, but it does not show anything. What am I doing wrong? Is there a better way of doing this? Your help is much appreciated. Thank you. PS. I could find Tutorials showing Master/Details retrieving records in a top down fashion (1:n), but I could not find the reverse (n:1)
I have a friend who has installed MSDE over SQL Server 6.5 - by doing so he broke some other apps that required a SQL 6.5 DB, he realises now it was a mistake on his part and would like to revert to SQL 6.5 again and recover his data, is this possible or has he lost all his old data?
1. Is there a stored procedure, or a way to reverse engineer a database? I have a lot of legacy dbs that I have inherited that I need to create a recovery system for. Part of this is creating the scripts to build all of the tables and I would like to automate it.
2. How can I output the results of a stored procedure to a text file? When I run sp_configure I would like that information to go to a text file.
I have built several cubes. However I would need to create local cubes from the built cubes in Analysis Services. As a result I need to work out the DDL for my existing cubes. However the cube contains many mdx calculated members. I was wondering if it would be easier to simply generate the DDL from my existing cube in Analysis Services.
Does anyone know any third party tools that I can use to reverse engineer the DDL from the built cubes in Analysis Services ?
I`d like to find a script that will create a "create" script for an entire database. It would write a create-table script for every table in the database, complete with all the PKs and FKs too.
Since I`m asking for the world (or at least the world`s creation script), then I`d also like the script to (optionally) write insert statements for all the rows currently residing in all the tables.
Do you have such a script? If not, can you give me a couple of pointers to assist me in writing my own?
I need to search a string starting at the end to find the last space in the string, so I can determine the position of the last word in the string. Any ideas on how to do this are greatly appreciated. Kellie
does anybody know of a script which can reverse engineer a database to a flat file - aprt from the one which is in enterprise maanger. I want to schedule a job to run once a week to compare the DDL of the database to make sure there are no changes ?
I have notice that i missed few columns in my merge repliction and i wonder is it possiblie to reverse a replicated database or copy to normal SQL database?
In Crystal Reports, there was a "reverse sign for display" property that could be checked for a number box. This was used for debits and credits (and such) so a negative number would be displayed as a positive and a positive displayed as a negative.
How would this work, or is there something simple, in Reporting Services?