|
I created a search stored procedure that accepts a parameter to perform the search with. I need to use this parameter with the LIKE and use also the '%" if it is possble . This is the code that i am using
WHERE (tbl.User LIKE '%'+@parameter+'%')
is it good?
thanks
|
|
|
|
|
Yes it seems good, but test it and you will be sure if it works properly.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
I would be more inclined to do the following:
WHERE (tbl.User LIKE LTRIM(RTRIM(@parameter))+'%')
Particularly if the parameter is from user input as:
-There may be white space at the beginning or end of the parameter.
-As it is a User you are looking for it may be better not to have the % at the beginning as you may get User(s) returned that contain the parameter within them rather than at their start.
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
hi,
how i use .asmx web service with sqlServer user defined function?
best regards.
|
|
|
|
|
You do a select, just like a columns
select dbo.udf_function(.....)
Bob
Ashfield Consultants Ltd
|
|
|
|
|
dbo.udf_function(how connect asmx web service. please can you write how to connecting asmx web service code here )
|
|
|
|
|
i want to use the database which is in the variable. I try the following codings but it is not work. Please help me this is argent.
declare @s as type
set @s='Nothwind'
Use @s
ssss
|
|
|
|
|
DECLARE @QueryValue varchar(1000) <br />
<br />
DECLARE @databasename sysname <br />
SELECT @databasename = 'mydatabase' <br />
SELECT @QueryValue = 'Select * from ' + @databasename + '.dbo.TableName'<br />
<br />
EXEC (@QueryValue )
hope it will helps
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
I am using MYSQL for generating some reports using LogiXML.The problem is that date format in mysql is yyyy-mm-dd and i need this to be converted to UK Format(dd/mm/yyyy).In report i am inputting date in dd/mm/yyyy and should return value matching corresponding dates.If i'm directly querying a value with date like
select DATE_FORMAT(dateIn, '%d/%m/%Y') as 'Date Arrived' from Employee where DATE_FORMAT(dateIn, '%m/%d/%Y') BETWEEN
DATE_FORMAT('2008-04-23', '%m/%d/%Y') AND DATE_FORMAT('2008-05-13', '%m/%d/%Y') is returning records which are not between these dates.
This is very urgent
Thanks
Anup
|
|
|
|
|
Table A :
id name sid jid
Table B:
bid img sid jid
select A.id,A.name,A.sid,A.jid,B.bid,B.img
from A left outer join B
ON A.sid=B.sid AND A.jid=B.jid
I wrote sql like this.
is right?
"ON A.sid=B.sid AND A.jid=B.jid" is key.
|
|
|
|
|
Yes. This usage is porper, to check for multiple columns.
Regards
KP
|
|
|
|
|
|
Hi Friends,
I am facing a very bad problem.I have added an SQL Database using VS 2005>>Add New Item>>Sql Database.The problem I am facing is not able to execute an INSERT or UPDATE.But the thing is that just after inserting and viewing the contents of the same table in the same event,the inserted record is displaying.But if I close the application and look into table manually I couldn't see the newly entered record.
ExecuteNonQuery() is working and no exception is thrown.Please Help.Seems like some weird is happening .I dont have an SQL Server installed.I am using VS 2005 only to develop a database application.
Thanks in advance.
|
|
|
|
|
I'd say your ExecuteNonQuery is NOT working.
At the end if your insert procedure (I assume you are using a stored proc and have an identity field on the table) add Select @@Identity as ID and user executeScalar to get the ID of the inserted record into a variable and inspect that variable in your UI.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Holmes,
Thanks for the reply.
I think the ExecuteNonQuery() is working because I have displayed the return value of cmd.ExecuteNonQuery().Also I have displayed the identity value as you mentioned.It is showing.Only thing is after closing the app new record is not showing up in the db when I see manually.
After adding a database like I mentioned before this is the connection string that is generated in app.config : -
<add name="crStudy.Properties.Settings.Database1ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
|
|
|
|
|
Guys,
I have a problem with a stored proc in SQL Server 2000. I'm logged in as 'sa' so have complete access to the DB. I have a table defined as follows:
CREATE TABLE Conduit (
Index_i int IDENTITY (1,1) NOT NULL Primary Key,
Name_vc nvarchar(125) UNIQUE NOT NULL,
StartDate_dt datetime
)
GO
I then have 2 stored procs that access it:
CREATE PROCEDURE ReadConduitNames
AS BEGIN
SET NOCOUNT ON
SELECT Name_vc FROM Conduit
END
GO
and
CREATE PROCEDURE ReadConduit
{
@Name_vc nvarchar(125)
}
AS BEGIN
SET NOCOUNT ON
SELECT * FROM Conduit WHERE Name_vc = @Name_vc
END
GO
The first stored proc runs fine, but the second one gives the following error:
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation
I've tried various forums and msdn, but can't find an answer as to why the second stored proc won't load.
Any thoughts?
Thanks in advance,
John.
|
|
|
|
|
replace
jgrogan wrote: CREATE PROCEDURE ReadConduit
{
@Name_vc nvarchar(125)
}
with
CREATE PROCEDURE ReadConduit<br />
(<br />
@Name_vc nvarchar(125)<br />
)
for more info check this google result[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
Many thanks - that worked a treat!
|
|
|
|
|
No problem
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
Rename you to Eagle Eyes - well done
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yeah - I was staring at it for 2 minutes before I realised where the difference was
|
|
|
|
|
Hi again and sorry for the delay. Thank you very much for your answer and here is the code I am using
RSClientPrint.MarginLeft = 0;
RSClientPrint.MarginTop = 0;
RSClientPrint.MarginRight = 0;
RSClientPrint.MarginBottom = 0;
RSClientPrint.Culture = 2058;
RSClientPrint.UICulture = 2058;
RSClientPrint.PageWidth = 85.2;
RSClientPrint.PageHeight = 279.4;
RSClientPrint.Print('http://ServerName\SQLinstance/ReportServer', '/FolderName/Impresion_Factura/Factura&CODIGO_SERIE='+serie+'&ID_SUCURSAL='+sucursal+'&CAJERO='+cajero+'&NIT='+nit+'&SUBTOTAL='+subtotal+'&DESCUENTOS='+descuentos+'&CODIGO_CAJERO='+codigo_cajero, 'Factura');
I really appreciate your help. You guys always get me out of trouble!!!
|
|
|
|
|
And you question is?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
Hi, sorry about not posting the question again. My problem is that when I preview the report, there is no problem with the first page, but if it is a long report, and I try to view the second page, it shows an error.
In the report server, all pages can be viewed ok. So this happens only when previewing and printing the report.
Thnk you very much for your help.
|
|
|
|
|
Try to fix it by adding code in report event (something like Initialize) which calls report data from database.
What error message do you get?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|