Skip to content

Tag: sql-server

add bool column within existing table

I am trying to dd a column, to a database with the program Microsoft SQL Server Management Studio. I already have a database, with a table, in that table i need to add another column.. but it keeps saying it cannot find type bool or boolean. my code : Any ideas ? side question, any idea how to alter an

Is there a LastIndexOf in SQL Server?

I am trying to parse out a value from a string that involves getting the last index of a string. Currently, I am doing a horrible hack that involves reversing a string: To me this code is nearly unreadable. I just upgraded to SQL Server 2016 and I hoping there is a better way. Is there? Answer If you want

SqlCommand only returns one row

Trying to only return the first few number of rows because my database was too big, however when I was testing my SQL, I did a select * and was only returned the first row. What is wrong with my solution? Answer In your loop you constantly re-create the instance of the variable logs thus overwriting the previ…

SQL – Remove all HTML tags in a string

In my dataset, I have a field which stores text marked up with HTML. The general format is as follows: <html><head></head><body><p>My text.</p></body></html> I could attempt to solve the problem by doing the following: However, this is not a strict rule as some …

Hide characters in email address using an SQL query

I have a very specific business requirement to hide certain characters within an email address when returned from SQL and I have hit the limit of my ability with SQL to achieve this. I was wondering if someone out there would be able to point me in the right direction. Essentially, my business is asking for t…