473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL delete Statement return 0 rows

33
hi could anyone help me fix my code..

i executed this line of code
Expand|Select|Wrap|Line Numbers
  1.  
  2. delete from Test.dbo.Test where Password='0x4465727374696E65'
  3.  
  4.  
the password column has a data type of varbinary and i inserted a string into it.

now i have a problem querying the table, i need to convert the varbinary data type into string and at the same type i want to display the ID column.
Aug 22 '14 #1

✓ answered by Jim Doherty

Username as in what? is that a statically stored value in your table or SQL servers own user/roles mechanism. If it is a statically stored value within your table then the SELECT statement can be expanded to include that column in the usual manner.

I am not at all clear on what it is you need Denden from your original post as it is not explicit enough in terms of your framework to enable me to make a concise judgement on this.

Can I suggest you read the SQL server (BOL books online) or the plentiful material that exists related to SQL statements on the net.

My perception of this is that you want to return a dataset of ID, UserName and Password in which case a simple SELECT statement crafted as such, would suffice, if that data is stored in your test table ie:

Expand|Select|Wrap|Line Numbers
  1. SELECT ID,UserName,CAST(password AS VARCHAR(MAX)) FROM Test

4 1682
Jim Doherty
897 Expert 512MB
Hello Denden,

Look at CAST and CONVERT functions for SQL server but here is a pointer for you from the perspective of a SELECT statement

Expand|Select|Wrap|Line Numbers
  1. declare @v varbinary(max)
  2. set @v = 0x4465727374696E65
  3. select * from [dbo].[Test] where [password]=CAST(@v as varbinary(max))
Aug 22 '14 #2
Denden
33
Thanks sir. i will try that when im at home. God Bless

update.. the password column didnt change to string :(

i tried to run this code
Expand|Select|Wrap|Line Numbers
  1. SELECT CAST(password AS VARCHAR(MAX))
  2. FROM test
it works but the problem is, it just return the password column, i also want to return the Username column.
Aug 23 '14 #3
Jim Doherty
897 Expert 512MB
Username as in what? is that a statically stored value in your table or SQL servers own user/roles mechanism. If it is a statically stored value within your table then the SELECT statement can be expanded to include that column in the usual manner.

I am not at all clear on what it is you need Denden from your original post as it is not explicit enough in terms of your framework to enable me to make a concise judgement on this.

Can I suggest you read the SQL server (BOL books online) or the plentiful material that exists related to SQL statements on the net.

My perception of this is that you want to return a dataset of ID, UserName and Password in which case a simple SELECT statement crafted as such, would suffice, if that data is stored in your test table ie:

Expand|Select|Wrap|Line Numbers
  1. SELECT ID,UserName,CAST(password AS VARCHAR(MAX)) FROM Test
Aug 23 '14 #4
Rabbit
12,516 Expert Mod 8TB
I hope you hashed the password, it's very poor security to store it in plain text.
Aug 24 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jeff Kish | last post by:
hi. I've seen ways to delete duplicate rows. Can someone give me some sql to do this? I have a table with varchar table_name_start, varchar column_name, varchar table_name_end; it has rows...
4
by: AlanAylett | last post by:
Hi all wondering if anybody could spot anything wrong with this SQL DELETE statement, both my Access and SQL skills are not what they used to be so i reckon its something simple, any suggestions...
1
by: Matt | last post by:
I am writing a DELETE statement and I want to filter the records using another SELECT statement. My SELECT statement is a GROUP BY query that grabs all social security numbers from the "Data...
0
by: crljenica | last post by:
I need to turn this select statement into a delete statemen. In other words, I want the results of the select statement deleted from the tables. I have never used a delete statement with a minus...
3
by: atrottier | last post by:
I'am new here so I'd like to say hello and this seems to be a great site it has already helped me a few times. I just got an assignment to correct and modify a simple access application. First some...
7
by: rasmidas | last post by:
I have the following function and there is memory leak as there is no "delete" for the corresponding "new". I am confused where to add delete. Kindly let me know where all to add the delete...
3
by: zaiena | last post by:
hi, i'm working in asp.net using visual studio 2005 with vb language, my tables is access database, will i'm trying to write the delete statement to delete some fields in my tables i wrote this...
1
by: codedhacker | last post by:
I have a piece of code that uses the db-library with sql server 2000/2005 and runs the following delete statement: DELETE FROM TABLE1 WHERE COL1 IN( 'Some Val1' ) AND COL2 IN( 'Some Val2' )...
1
by: Ample | last post by:
I need a delete statement to delete records using the below select statement. I got a mind block as to what should be used in the where clause column operator. DELETE from InvOnHand WHERE...
0
by: jeddiki | last post by:
Hi, I need to delete excess rows from my table, but ı am not sure how to do it. I don't need more than two updates to any item per day so I want to delete extra ones from the table. I can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.