|
in the database i want to store images for each employee ,to do this in sqk server 2005 there is a data type called image which is defined under binary ,How ever i want to know the way to store an image in the data base and retreive it from the data base ...
|
|
|
|
|
Convert the images to bytes and send the bytes to your database!
Steps
Create a stream object
Assign your image to the stream
Copy the contents of the stream to byte array
Send the byte array to the database
gauthee
|
|
|
|
|
thank you for your kind reply ,could you please explian it bit more , i'm using c# and do i have to do this from the application or when inserting valued into the table in sql server .
|
|
|
|
|
Convert the data into bytes in your application and then pass the byte stream across to SQL Server.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
hi here is a cool link for storing the images in sqlserver database.
this is a combination of sqlserver and .net application
i check it its working fine we need to modify a little bit accoridng to our requirement.
plesase get back for any clarifications.
here is the link.
http://www.aspdotnetcodes.com/Insert_Images_Database.aspx[^]
|
|
|
|
|
Hi,
How to calculate no of sundays in between two dates in sql.
Thanks in advance.
|
|
|
|
|
There is no system defined function for this task!
For this you have to write a userdefined function/stored procedure
For the function/store procedure send the start and end dates as input parameters
Declare a variable with value as 0 for count purposes
check the day of the start day using the datepart function
if weekday is sunday increase the count by 1
Continue the steps till the end date
return your count
gauthee
|
|
|
|
|
-- modified at 4:20 Monday 3rd September, 2007
sorry guys,
the query doesn't work....
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
hi i check it this is not working fine here is the example.
declare @startdate varchar(10)
declare @enddate varchar(10)
set @startdate='08/01/2007'
set @enddate='08/31/2007'
SELECT (DATEDIFF(day, @StartDate, @EndDate)/7) + (SELECT CASE WHEN (DATEDIFF(day, @StartDate, @EndDate)%7) > 0 THEN 1 ELSE 0 END)
This returns me 5 instead of 4.
|
|
|
|
|
hi here is the code for calculating the no of sudays between two given sqldates.
create PROCEDURE pr_displaysundays
-- Add the parameters for the stored procedure here
@fromdate varchar(10),
@todate varchar(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
SET NOCOUNT ON;
declare @diffDay int
declare @Cnt int
declare @Nos int
select @Diffday=datediff(day,@fromdate,@todate)
set @cnt=0
set @Nos=0
while @cnt<@diffday
begin
if datepart(dw,cast(convert(varchar(10),@fromdate,101) as datetime)+@cnt)=1
begin
set @Nos=@Nos+1
end
set @cnt=@cnt+1
end
print @Nos
END
|
|
|
|
|
I answered this same question back in April. For a psuedo-code solution, check out http://www.codeproject.com/script/comments/forums.asp?msg=1993362&forumid=1725&mode=all&userid=3403440#xx1993362xx[^]
For a SQL solution, see http://www.codeproject.com/script/comments/forums.asp?forumid=1725&mode=all&userid=3403440&select=1993823&df=100&mpp=50&fr=4038#xx1993823xx[^]
Here is some of my personal code I use within Access. I have tested it, and use it within my projects.
CREATE PROCEDURE numCertainDays(date1 DATE, date2 DATE, wkdy INTEGER) AS
SELECT CINT(@date2 - @date1) \ 7
+ IIF( WEEKDAY(@date2) < WEEKDAY(@date1), 1,
IIF( WEEKDAY(@date2) = @wkdy OR WEEKDAY(@date1) = @wkdy, 1, 0 ))
;
To get the number of Sundays, you would call it with wkdy=1.
David
|
|
|
|
|
from amployee table i want to get 10 employees who get the heigest 10 salaries . To do this how can i use the max function , or is there any other way to do this .
|
|
|
|
|
Use the order by on the salaries instead. If you order by descending, then the highest salaries will be first. If you don't care about duplicate salaries this is the way to do it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thank you for the reply, but i want to get the first ten max salaries and don't care about duplication ..
|
|
|
|
|
Then, use select top 10 ... from ... order by salary desc .
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thank you very much ,I think it will help me ...;)
|
|
|
|
|
You are welcome
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
hi Prasadbuddhika
SELECT top 10 *
FROM Scoring
WHERE Score = (select Max(Score) from Scoring);
hope it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
thank you very much ,I think it will help me...;)
|
|
|
|
|
Have you really run that?
This query does not return the desired result. It returns only the record with the max Score.
And up to ten records when multiple records hold the max score.
@Prasadbuddhika:
Furthermore this is a very basic requests, therefore I suggest investing some time in studying!
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
|prasadbuddhika wrote:
from amployee table i want to get 10 employees who get the heigest 10 salaries
And he is not complaining its working for him and it brings desired results for me too
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
I have been told the answer is very simple - but despite asking on many forums nobody has given me the answer.
Could you help me.
What would the code in VB.net, to - within a single msaccess database - (on a batch basis) examine a record in one table, and then dependant on the results of the examination(ie the value of a status field), add a new record to a second table, and then continue looping through this function until the end of the first table.
Sorry if it seems simple - but I think I am - simple that is...
:->
|
|
|
|
|
The approach of retrieving and looping through individual records is very time consuming when you consider that SQL is set based. Consider using an INSERT INTO based on a select instead. Here's an example:
INSERT INTO table2 (value1, value2, value3)
SELECT value1, value2, value3
FROM table1
WHERE status = 'Hello' This will insert all the records that match the criteria in table1 into table2.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I am schema qualifying a stored procedure when calling it such that if I have a database named 'MyDB1' and the stored procedure 'GetContacts' that belongs to 'dbo' schema, I can call it like:
EXEC MyDB1.dbo.GetContacts
However, I need to be able to dynamically call the stored procedure from different databases that that have the same stored procedure such that i can call them like:
EXEC MyDB1.dbo.GetContacts
EXEC MyDB2.dbo.GetContacts
EXEC MyDB3.dbo.GetContacts
Is there a way I can use a variable name in place of the database name such that I can call the stored procedure like:
DECLARE @DBName NVARCHAR(20)
SET @DBName = 'MyDB1'
EXEC @DBName.dbo.GetContacts
and so forth, ...
Or, what options do I have?
|
|
|
|