Showing posts with label keyword. Show all posts
Showing posts with label keyword. Show all posts

Thursday, March 8, 2012

Can i use Top keyword in SQL Server 2003?

Top keyword does not work in SQL server 2003. It works perfectly with SQL server 2005. Can any1 tell me how to extract top 10 rows in 2003 server. I guess rowcount also doesnt work with SQL server .Hai Vaishali!

In this case you can add an id field which acts like a row number. Then you can use the following query

select * from mytable where id between 1 and 10

It will return top 10 rows
Hope this will work

All the Best

With Regards
Vijay. R|||SQL server 2003 ?

Saturday, February 25, 2012

Can I use keyword Like with a Parameter

Should be simple. I'm writing a report to find employees by last name.

I want the user to key in at least a few characters of the last name and the report will search for all last names that are like that.

I know in TSQL it would go:

Last_name like 'Jones%'

But how do I set up a parameter in Reporting Services

I've tried:

last_name like =@.name%

Any ideas?

Thanks,

Jim

Any ideas? Can the Keyword "Like" be used to find similar occurences of a user entered parameter...|||Within the dataset query you can declare a variable that references the parameter with the text then append the necessary % to the end. So the reference would look something like...

DECLARE @.some_variable NVARCHAR(40)
SET @.some_variable = @.parameter_field_text + '%'

You can then use this...

SELECT *
FROM some_view
WHERE NameField LIKE @.some_variable|||

You would probably need to use dynamic sql and expression.

="Select * from table1 where last_name like '" + @.name + "%'"

Or use a stored procedure and perform the like statement within it.

cheers,

Andrew

Friday, February 24, 2012

can i use "translate" in sql server,is it a keyword

im trying to find the equivalent of the below oracle code in sql server.But to my knowledge i feel "translate "is not supported by sql server. so please send me the equivalent sql server query for this.

SELECT 'http://ploft.com/ploft?y='||translate(comp,' ','+')||',+'||translate(california,'
','+')||',+'||ca||'+'||pz
INTO :ls_MAP FROM project WHERE portno=:dbno;I believe the REPLACE function is what you are after in SQL Server.|||thank you crowley

how to use 'replace' function to change the characters in a given column.In oracle we can do that (its in above query)|||http://msdn.microsoft.com/library/en-us/tsqlref/ts_ra-rz_76lh.asp?frame=true

replace (query, 'TRANSLATE', 'REPLACE')