|
i have an interesting question for you guys.
SELECT S.SCHOOLID AS [SCHOOLID],S.SCHOOLNAME AS [SCHOOLNAME],SP.PHOTO AS [PHOTO]
FROM SCHOOLPHOTO SP
INNER JOIN SCHOOL S
ON SP.SCHOOLID = SP.SCHOOLID
WHERE S.SCHOOLID IN (SELECT SCHOOLID FROM #SCHOOLS)
the Photo Field is an Image Datatype Field, i now you can use them in a Distinct or group by , How can i go by have that field there without casting it , because if i cast it it will not work together in Silverlight or any other image control.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
How about generating a hash code for your image and store that value in your table along with the image. You could then use the hash code in your group by clause.
check this article out ...
http://www.vcskicks.com/image-hash.php[^]
It was the first thing that popped up in my Google search.
Good luck.
|
|
|
|
|
I need a Solution in T-SQL
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
What version of SQL Server are you using? If it's sufficiently advanced, you could apply this as a CLR Trigger.
|
|
|
|
|
I am SQL 2008
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Then it's job done. You can use a SQL CLR trigger and store the hash when the image is inserted or updated.
|
|
|
|
|
this did the Job
;with cteSchools as (SELECT DISTINCT S.SCHOOLID AS [SCHOOLID],S.SCHOOLNAME AS [SCHOOLNAME]
FROM SCHOOL S
WHERE S.SCHOOLID IN (SELECT SCHOOLID FROM #SCHOOLS))
SELECT S.SCHOOLID AS [SCHOOLID],S.SCHOOLNAME AS [SCHOOLNAME],SP.PHOTO AS [PHOTO]
FROM cteSCHOOLS S
CROSS APPLY (Select TOP (1) PHOTO from SchoolPhoto SP
WHERE SP.SCHOOLID = S.SCHOOLID
ORDER BY SCHOOLID DESC) SP
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Use the T-SQL function hashbytes like this:
select hashbytes('MD5', 'your value')
|
|
|
|
|
I'm trying to export the results of a stored procedure to a csv, here's what I've got:
"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe" myDb.dbo.spExport out "Data.csv" -T -Slocalhost -t";" -c
It keeps telling me "Invalid object name 'myDb.dbo.spExport'."
Other stored procedures don't work either and none require parameters.
Pointing to a table works so I thought I was pointing to at the SP's the right way.
What am I doing wrong?
-Nevermind, got it working:
"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\bcp.exe" myDb.dbo.spExport queryout "Data.csv" -T -Slocalhost -t";" -c
modified on Tuesday, May 31, 2011 10:08 AM
|
|
|
|
|
|
Hi all, I have a MSSQL database with Godaddy, and I have access using the SQL Server Managements Studio, and of course their Hosting center interface with a web browser.
I need a more robust backup setup. Currently I would have to manually initiate a backup.
-Is there a way to automate a backup using The Sql Server Management Studio? Perhaps from my client PC (COM, DLL)?
-I can't use the BACKUP command statement as the server is attempting to create the backup file on THEIR servers. The only information I'm using the database is table data. If using .NET along with the SQL database, are there any methods (that would be reasonably affective) to SELECT statement for each table in db. Then export this database to csv or other format.
Appreciate your help.
|
|
|
|
|
How about creating the back on their servers and then ftping the backup files to your server/computer?
|
|
|
|
|
IMO, the only place where you can backup the databases on a server is on the server itself. What you can do is to write a script to execute the BACKUP command and FTP the file from the server to your PC/Laptop.
modified on Tuesday, May 31, 2011 7:11 AM
|
|
|
|
|
If I may ask, how is your answer different from mine?
|
|
|
|
|
I did not read your post.
|
|
|
|
|
No problem
|
|
|
|
|
Hi,
Can anyone provide me with a link for tutorials on stored procedures?
Thanks
Cheers
Nikhil
|
|
|
|
|
Everyone can[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Depends on what Database you're targetting.
|
|
|
|
|
I have two tables that are identical, 1 table has old data and the other new data.
I want to copy the old to the new where the records are either blank or null is there an easy way I can do this.
Any help is appreciated.
Thanks in advance,
Michael
|
|
|
|
|
Which column is unique on both tables?
Syntax is like this:
Insert into table2 (col1,col2,col3)
select col1,col2,col3 from table1
In this select statement you have to include where clause with unique column in table1 and tale2
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Are they in the same database? Are they on the same server? Are they the same brand of database?
When I had to copy data from an Ingres database on a Unix system to an SQL Server database on Windows there were times I had to simply throw the records at the database one by one and catch-log-and-ignore any duplicate Exceptions encountered. Simple but effective, and quicker than trying to test each record first.
|
|
|
|
|
They are in the same DB on the same server.
I copy all the old records to a similar table
Delete the orig table's records
Start with a blank table, this is a starting point to build other info, I do not want many of the records from the old included which I do not know until I start new.
Add new data
Then I want to insert old data where new data is left blank and do not wish to overwrite new data.
The previous response said the following:
Insert into table2 (col1,col2,col3)
select col1,col2,col3 from table1
I am thinking if I used the above then added
Where col1 IS LIKE '' or col1 IS NULL
but I would have to do this for every column, I was hoping there would be a quick easy way
Michael
|
|
|
|
|
Might help to know which database vendor you are referring to.
Easy is relative.
You can do an update statement with a 'case' for each column.
|
|
|
|
|
SQL Server supports a rather convenient MERGE[^] command that lets you specify criteria of two records being 'identical', actions to take on finding a match, and actions to take on finding missing records. The documentation at the link supplies several large examples, so you should be able to construct your statement relatively easily.
|
|
|
|