|
rohitgraycell wrote: but internet says that sp_executesql only accepts nvarchar/ntext datatype
You may wish to take a closer look at the documentation sp_executesql[^]
For example:
sp_executesql 'SELECT * FROM MyTable WHERE someColumn = @someIntParam',
'@someIntParam INT',
@someIntParam = 12;
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Aloha,
Some genius have upgraded our SQL Server (Server1) to version 2005. This is bad since we need to restore a database from Server1 to another server that only runs version 2000 (Server2).
Is there some way we can backup our database in version 2000 format? I have tried a lot of things, but we always seems to end up with something that Server2 doesn't want to eat
Thank you for your help,
phi
phimix.com 
|
|
|
|
|
Hi..
I have .NET application that traks projects. I want to be able to create search page that will allow me to search project by title, description, etc.
I was able to create a search page and search functionality as well. The only problem I have is when I search within description user must type exactly word to word as description is in DB (an it can be long one). In my SQL statement I use LIKE to match what user types and datatbase entry. Is there anyway around it? Maybe I should use something else (I'm not sure what because I'm not a big SQL guy). The other thing is I need a way around case sensativity project 1 is not PROJECT 1.
Any help would be very welcome.
Thanks,
|
|
|
|
|
SELECT p.title, p.description <br />
FROM project p<br />
WHERE UPPER(p.description) LIKE '%' + UPPER(@cSearchString) + '%'
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
Thansk a lot bro. I got figure it out.
The funny thing is I used LOWER function.
Thanks again. I really appreciate it.
|
|
|
|
|
alexfromto wrote: The other thing is I need a way around case sensativity project 1 is not PROJECT 1
That could be hard, because the default installation of SQL Server is not case sensitive. You could try converting both strings to varbinary (to preserve case sensitivity), altough I'm not sure how you would compare them.
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
Hi All... Currently i am doing my banking application using ASP.Net,C#, SQL Server2000... i want some technical solution realated securities from you guys as follow..
i already logged to my application by using username and password.. after login page my home page Home.aspx coming on screen.. i have features all like Balance Inquiry, Mini Statement, Last Transaction, Private Banking, Net Banking in my Home Page in left menu side. All Features are working very well.. For Security Reason i want some technical help from all of you guys...
Problem is After my successful login page If i not touch the Home page or if i not click on any features available in home page for 10 minutes.. Like if i click on Balance Inquiry Link after 10 minutes that time Page Login.aspx want to open instead of BalanceInquiry.aspx... After my successful login by username and password i want to open page BalanceInquiry.aspx (do not want open Home.aspx Page Again)... For that what i have to do in my Application to make more secure... if u have any articles link then please send me..
Please Please Help me if you people have some technical solution... Bcz right now i am on mid way of that project... if u have any articles or articles link please help me out....
Regards,
Patel...
|
|
|
|
|
|
Toasty0,
Thank you for providing fellow Cpians with the informative link.
Paul
|
|
|
|
|
Hi
I have one GridView and in this gv i have two column one is mark-printer other is model-printer.So i done this column like template but i don't know how to do exchanging of data when i doing edit???I mean if i choos for example "HP" i want to see only models for hp not all how to link both controls pleas help me.
Good bye best regards
|
|
|
|
|
I have a function which is used as a default in a number of tables/columns.
I want to alter that function but when I do an "ALTER FUNCTION..." bit of SQL it tells me it can't be altered because it is in use - does anyone have a handy "drop all the defaults, alter function, reinstate all the defaults" type script I could cadge?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|

<br />
create table tempdb..DEJ_Constraints<br />
(<br />
table_name sysname,<br />
constraint_name sysname,<br />
constraint_text varchar(1000),<br />
column_name sysname<br />
)<br />
go<br />
<br />
<br />
insert into tempdb..DEJ_Constraints<br />
select object_name(sysconstraints.id) as table_name,<br />
object_name(sysconstraints.constid) as constraint_name,<br />
syscomments.text as constraint_text,<br />
syscolumns.name as column_name<br />
from (syscomments inner join sysconstraints on<br />
syscomments.id = sysconstraints.constid) INNER JOIN syscolumns<br />
on syscolumns.id = sysconstraints.id <br />
and syscolumns.colid = sysconstraints.colid<br />
where syscomments.text like '%GetNextkey%'<br />
go<br />
<br />
-- Drop any existing constraints that use the function...<br />
declare @table_name sysname,<br />
@constraint_name sysname,<br />
@command varchar(1000)<br />
<br />
declare constraint_killer cursor for<br />
select table_name, constraint_name <br />
from tempdb..DEJ_Constraints<br />
<br />
open constraint_killer <br />
<br />
<br />
FETCH NEXT FROM constraint_killer INTO @table_name , @constraint_name<br />
<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
SELECT @COMMAND = 'ALTER TABLE ' + @table_name + ' DROP CONSTRAINT ' + @constraint_name<br />
<br />
EXECUTE(@COMMAND)<br />
<br />
print 'Executed : ' + @command <br />
<br />
FETCH NEXT FROM constraint_killer INTO @table_name , @constraint_name<br />
END<br />
<br />
close constraint_killer <br />
<br />
deallocate constraint_killer <br />
go<br />
then alter the function then..
<br />
declare @table_name sysname,<br />
@constraint_name sysname,<br />
@column_name sysname,<br />
@constraint_text varchar(1000),<br />
@command varchar(1000)<br />
<br />
declare constraint_builder cursor for<br />
select table_name, constraint_name , constraint_text, column_name<br />
from tempdb..DEJ_Constraints<br />
<br />
open constraint_builder <br />
<br />
<br />
FETCH NEXT FROM constraint_builder INTO @table_name , @constraint_name, @constraint_text ,@column_name <br />
<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
SELECT @COMMAND = 'ALTER TABLE ' + @table_name + ' ADD CONSTRAINT ' + @constraint_name + ' DEFAULT ' + @constraint_text + ' FOR ' + @column_name <br />
<br />
EXECUTE(@COMMAND)<br />
<br />
print 'Executed : ' + @command <br />
<br />
FETCH NEXT FROM constraint_builder INTO @table_name , @constraint_name, @constraint_text , @column_name <br />
END<br />
<br />
close constraint_builder <br />
<br />
deallocate constraint_builder <br />
go<br />
<br />
drop table tempdb..DEJ_Constraints<br />
go<br />
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I need a count column and 2 other columns in the select query. Consider the following query:
select locid,lname,count(deviceid) AS count<br />
from failures<br />
group by locid
The above query will not work because Column 'LName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
How can i get both the locid and lname?
Thanks
-- modified at 12:17 Wednesday 19th April, 2006
|
|
|
|
|
dansoft wrote: How can i get both the locid and lname?
Add both columns to the GROUP BY clause.
GROUP BY locid, lname
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
thanks working ![Rose | [Rose]](https://www.codeproject.com/script/Forums/Images/rose.gif)
|
|
|
|
|
The following sql join query is displaying "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" error
SELECT failure.locid,device.count,failure.count<br />
FROM<br />
{<br />
SELECT locality.locid,count(*) AS count<br />
FROM allotment,locality<br />
WHERE allotment.locid=locality.locid<br />
group by locality.locid<br />
} AS device<br />
FULL OUTER JOIN<br />
{<br />
SELECT locid,count(deviceid) AS count<br />
FROM failures<br />
group by locid<br />
} AS failure ON device.locid = failure.locid
device is used to find number of device in a particular locality
failure is to find the number of failures in the particular location
Both device and failure queries are working fine separately.
All localities are stored in locality table. the alloted devices are in allotment table, failures are in failures table
Please correct the error in the query. Thanks.
|
|
|
|
|
dansoft wrote: {
I've never seen that type of bracket/brace used in SQL. Use the normal brackets ()
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Colin Angus Mackay wrote: Use the normal brackets ()
Sir, where i have to use the normal brackets () ?
|
|
|
|
|
Oh Sorry, i'll change the bracket.
Thanks
|
|
|
|
|
dansoft wrote: Sir, where i have to use the normal brackets () ?
Where do you think?
I highlighted the fact you were using braces {} and that it was wrong. Replace the {} with ()
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Hi,
Does Anyone know how to change the size of LEGEND Box in any chart of RDL File? There are many details in LEGEND area of my chart which makes legend area much congested.
Thanks in Advance
|
|
|
|
|
Hi,
why the select query is not returning the decimal value?
consider the following query:
select 1/2
it is returning 0
it must return 0.5 Please help.
Thanks
|
|
|
|
|
Because it is doing an integer division and truncating everything past the decimal point.
use SELECT 1.0/2.0
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I need to use the colname. for eg: select colname1/colname2 from table
the colname1 has the value 1 & colname2 has the value 2
thanks
|
|
|
|
|
Then cast the column values to float s
SELECT CAST(colname1 AS FLOAT) / CAST(colname2 AS FLOAT) FROM MyTable
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|