|
I know MS-SQL can connect to other databases to communicate to them with Linked Servers. Does anyone know if Sybase can do this? If so, how is this accomplished? Thank you in advance.
modified on Tuesday, January 22, 2008 9:49:42 AM
|
|
|
|
|
Hi,
I have an sp name Movie_SP which returns all the movies by taking MovieName
Now in my New sp(Search_Movies_SP) I want to use the out put of the first SP(Movie_SP)
and with the result of Movie_SP I have to manipulate
Actually I need to set priorities as my first SP Movie_SP is returning all the movies with say BLACK in an Improper way
I want to make it to a order where Black comes First,
then The Movies which starts with Black second,
and the third is The Movies which contains Black
Plz help me
thanks
Pashi
|
|
|
|
|
Could've been better if you have mentioned which database you are working with.Assuming that you are working with Sql Server...
pashitech wrote: use the out put of the first SP
Are you looking out for something like an Output Parameter[^]?
If no (which I assume so), I guess you'll have to populate the data onto a temporary table for manipulations.
pashitech wrote: make it to a order
You may try using the LIKE[^]operator.
Select * from tblMovies where MovieName = 'Black'
The above query fetches you details where the movie name is black (an exact match)
Select * from tblMovies where MovieName Like 'Black%'
The above query gives you details where the movie name begins with black (including black)
Select * from tblMovies where MovieName like '%Black%'
This one fetches movie names that contain the word black.
-- For better usage with the like operator, refer to the URL linked.
|
|
|
|
|
How about:
create table #temp1 (
--list of columns returned by Movie_SP goes here
)
insert into #temp1
exec Movie_SP @Param1, Param2, ...
select * from #temp1
order by case
when Title = 'Black' then 'A'
when Title LIKE 'Black %' then 'B'
else 'C'
end,
Title
You can use "insert into" to return the resultset of a stored procedure into a temporary table. The following select statement uses a case statement to prioritorise the ordering. You might need to tweak this a bit because I didn't quite understand your requirements.
Regards
Andy
|
|
|
|
|
I need to create a User Defined Type for time. I tried rewriting my database tables as shown below and I get the error that is shown below.
Do I need to do something else to create them? Do I need to use hh:mm for the formatting of the datapart I need to use?
All I need in ts_from and ts_to is the hour and the minutes.
I am using SQL Server Express 2005.
create table tbl_teach_sched (<br />
ts_id int NOT NULL IDENTITY(1000,1),<br />
teach_id int,<br />
ts_day text,<br />
ts_datetime datetime,<br />
ts_from as (datepart(hh:mm, ts_datetime)) persisted,<br />
ts_to as (datepart(hh:mm, ts_datetime)) persisted,<br />
primary key(ts_id),<br />
foreign key(teach_id) references tbl_teachers(teach_id));
This is the error.
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near 'hh:'.
Msg 132, Level 15, State 1, Line 8
The label 'hh' has already been declared. Label names must be unique within a query batch or stored procedure.
|
|
|
|
|
Yeah, you can't do that.
Either just use the DateTime, or use a smallint.
The smallint could be the number of minutes or seconds from midnight, or it could be hours*100+minutes.
But I spend so much time converting between time-storage schemes that I prefer DateTime; the savings in maintenance makes up for the waste of space.
|
|
|
|
|
I have a book taht suggests creating a user defined data type for time only? How is it that I can't create a user defined type for time alone?
|
|
|
|
|
I have Googled without success (I keep getting blog posts that deride Access/Jet SQL as 'sucking'* with a comment feature at the bottom of the page), but does anybody know how to code-comment Access/Jet SQL?
I'm attempting to show our resident VB "whiz" how he's left himself open to SQL Injection attacks - when his application targets SQL Server I can successfully hack his code in the manner described by various posts/articles by injecting my own SQL and by commenting out his, but in Access/Jet SQL it doesn't appear to work.
*Yes, I'm inclined to agree with the majority of these posts.
|
|
|
|
|
Hi,
I am new in the field of databases.
I am trying to create a strong typed dataset (using vs 2005 add data set wizard).
The table in my data base include foreign keys (relations).
When the wizard finishes the dataset is created with all the necessary tables and fields, EXCEPT for data relations.
When I am performing the same thing with access data base the relations are loaded well.
Does anyone have an idea of what it could be.
Sincerely yours
Y.R.
|
|
|
|
|
how would I select and count the number of values that match: j0107_a131 and show the following two values
j0107_a131
j0107_a131_01
the roomcode is in a string that is why i specified below 'like roomcode'
i.e. select count (room_code) from rooms where room_code like room_code
hope that makes sense cheers
|
|
|
|
|
Well, you could always do this:
select @room_code = @room_code + '%'
select count(room_code) from rooms where room_code like @room_code
|
|
|
|
|
i am using ASP.net, C# anD SQL Server2005,in the following query:
string q = "SELECT collapsed_building.b_name,collapsed_building.b_desc FROM collapsed_building WHERE collapsed_building.b_name LIKE '" + crimewithdate.text2 + "' ";
I WANT TO USE % AFTER THE KEYWORD like SO THAT ALL THE BUILDING NAMES WHICH MATCH THE VALUE ENTERED BY THE USER ARE DISPLAYED
WHEN I WRITE (LIKE '" + %crimewithdate.text2 %+ "'), IT GIVES ERROR, WHAT WILL BE THE CORRECT SENTAX
|
|
|
|
|
Please, don't do this. You leave yourself with open to a Sql Injection attack. Take a look at this[^] article on how to avoid this. Now, you many want to consider using something like this:
DECLARE @building_name NVARCHAR(100)
SELECT @building_name = 'Test'
-- The lines above are just a sample to get you started. Move this into a stored procedure and use
-- the code below to do the actual work. Note that you would want to determine whether or not
-- @building_name ended in a % before using this code.
SELECT @building_name = @building_name + '%'
SELECT collapsed_building.b_name,collapsed_building.b_desc FROM collapsed_building WHERE collapsed_building.b_name LIKE @building_name
|
|
|
|
|
Pete is correct in saying that this is dangerous code. You have to use strong
protection to make sure that crimewithdate.text2 does not contain
any malicious SQL code instead of the expected search parameter.
To answer your question as asked, here is one solution:
string q = string.Format("SELECT collapsed_building.b_name,
collapsed_building.b_desc FROM collapsed_building
WHERE collapsed_building.b_name LIKE '%{0}%'", crimewithdate.text2);
(The line breaks are for readability only)
Do realize that an evil user could enter something like;
x'; TRUNCATE TABLE collapsed_building; SELECT * FROM collapsed_building WHERE b_name LIKE 'x
and wreck your whole day.
It is much better to pass crimewithdate.text2 as a parameter and not expose your database to bad people.
modified on Tuesday, January 22, 2008 11:26:49 AM
|
|
|
|
|
Hi, i want to create a job.
http://msdn2.microsoft.com/en-us/library/ms191439.aspx[^]
By following this link, i did the same, but i unable to see the sqlserver agent in object explorer. i started the service in adminsitrative tools ->services. And also, i restarted the sqlserver. still not able to see sqlserver agent..can any one help regarding this.....
G. Satish
|
|
|
|
|
I have 2 Databases: in that, In the Database DB1, i write a stored procedure: In that i write
Select command for a the table that has to fetch from Database DB2.
How to write a Stored Procedure for this?
Regards,
LEE
|
|
|
|
|
If you are using SQL Server, identify your tables using the following naming convention:
databasename.owner.tablename
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Doing that sort of thing is generally a bad idea.
I have some code that does that and now we want to move one of the databases to a different server and can't without breaking the code. At best we could link the servers, but I'd still have to modify the code. (And we've had trouble with linked servers in the past.)
Plus, not all database systems allow that construct so it may lock you into SQL Server.
You may want to create a view that handles the cross-database query.
Anyway, be aware of the potential problems.
|
|
|
|
|
Hi freinds i want to develop crystal report which used different data source to dispaly different record in one singal report
There i have some Question
1 : Can i used Subreport for differnt datasource in main Crystal report and can i send parameter to them
2: can i useHide subreport i.e if i there is Condition to show subreport(a)
then all remain subreport shoul be hide mean to say shoe singal subreport in each case Can i do this Can some body tell me
wasim khan
|
|
|
|
|
|
Hi there,
Can someone tell me, is it possible in SQL Server 2005 how to Decrypt and Encrypted SP or View.
Mujtaba
"If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
|
|
|
|
|
The procedure encryption is actually referred to as obfuscation in Books Online. Also, there is no SQL Server command for decrypting it back. You could use third party components to accomplish this, there sure can be found some by searching in google for them.
The only feature for protecting code in SQL Server is the WITH ENCRYPTION clause (http://databases.aspfaq.com/database/how-do-i-protect-my-stored-procedure-code.html[^]). It is weak not necessarily because the encryption is weak (it uses RC4), but because the encryption key can be easily found. An attacker will focus on finding the encryption key rather than breaking the encryption algorithm in such a solution.
|
|
|
|
|
Hi, i want a procedure to schedule a job in sqlserver 2005.
How to create a job in sqlserver 2005?
G. Satish
|
|
|
|
|
This information is available in SQL Server BOL. Did it occur to you to read the documentation?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I cant understand your answer. I dont know anything regarding schdeuling and sqlserver agent also. I dont know BOL. what is this? can u give link rgarding this concept?
G. Satish
|
|
|
|