VB.NET : Change SQL Server Authentication mode

We are using the following code to change the SQL Server authentication from Windows mode to mixed mode. query.CommandText = “EXEC xp_instance_regwrite ‘HKEY_LOCAL_MACHINE’, ‘Software\Microsoft\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQLSERVER’, ‘LoginMode’, REG_DWORD, 2” query.CommandType = CommandType.Text query.ExecuteScalar() During the execution we get the following error. RegCreateKeyEx() returned error 5, ‘Access is denied.’ We could change the authentication mode manually. […]

Job with create table

I create a job with the following query CREATE TABLE P (ID INT IDENTITY(1,1) , [employee_name] varchar(10), [employee_salary] varchar(10)) INSERT INTO P ([employee_name] ,[employee_salary] ) VALUES (‘DANI’,’1000′) and i execute the job the following way use[msdb] EXEC dbo.sp_start_job xxx GO use[DEMO] select * from P my question is-why i did not receive a massage “table […]

How to convert sql offsetted datetime format back to default?

I’m offsetting a column for timezone difference. How to convert the returned datetime back to default as now it’s being shown with offset information in the column? ,SWITCHOFFSET(CAST(CREATEDDATETIME AS datetimeoffset) ,DATEDIFF(minute, GETUTCDATE(), GETDATE())) AS CREATEDDATETIMEPDT 2014-07-01 16:44:15.000 2014-07-01 08:44:15.0000000 -08:00

Split or duplicate records when more than 24 hours entered per day

We have an absence system where people are putting in their total time off instead of splitting it into different records. So my data looks like this EMP_ID | HOURS | DATE ———|———–|———— 1 | 24 | 2013-10-10 2 | 8 | 2013-11-06 3 | 48 | 2013-11-13 4 | 51 | 2013-12-10 I need […]

Which one is effective- filtering by narrowing or direct filtering

Which one of the below two will be faster, provided that invoice.userId and invoiceline.invoiceId both have indexes on it. invoice.id is a primarykey so even that has an index. select invoiceline.item, invoiceline.rate, invoiceline.vat from invoice inner join invoiceline on invoice.id = invoiceline.invoiceId where invoiceline.id = @invoiceId AND invoice.userId = @userId select invoiceline.item, invoiceline.rate, invoiceline.vat from […]

No Results from pyodbc using table type

I’m creating a #Temp table within this connection, then trying to convert that to a user defined table type and pass it to a stored procedure. this works fine in Microsoft SQL Server Management Studio, but i can’t get it to work in python using pyodbc. SET NOCOUNT ON; USE TestDB DECLARE @Temp as dbo.TempType; […]

how to search table through textbox?

I have piece of query that search database from text box. My question is how can insert search result column by column to separated text box, I mean each column go to one textbox. private void searchbtn_Click(object sender, EventArgs e) { SqlCeConnection con = new SqlCeConnection(@”Data Source=C:\Users\hry\Documents\Visual Studio 2010\Projects\Kargozini\Kargozini\khadamat.sdf”); try { con.Open(); string SearchQuerry = […]

SSIS and sending query with date to Oracle

I am trying to create a flow to pull data from an Oracle table into a SQL Server table. I am sending the following query to Oracle to get the data: select distinct CHLD.id, nvl(chld_c_spl, ‘N’), to_char(chld_d_start, ‘YYYY-MM-DD’) chld_d_start, to_char(chld_d_end, ‘YYYY-MM-DD’) chld_d_end from child chld, picture ptct where CHLD.id = PTCT.chld_id and nvl(chld_d_end, sysdate) >= […]

SQL Server 2012 Case statement cannot update what I need it to update

I’m trying to figure out how to make this formula work for my SQL Server 2012, and it has me completely stumped. In the first case statement where I am trying to set the Dateupdated column, on the middle line, I have it as WHEN standardunitcost > (averageunitcost + 2.000000) THEN GETDATE() I need to […]

Adding a file to SQL table – never saves

I am trying to update a column of datatype image with a local file Update tblabc set DOCBLOB =(Select * FROM OPENROWSET(BULK ‘C:\TEMP\abc.doc’, SINGLE_BLOB) AS img) where ID= 62 GO The query appears to execute correctly (no error) but the column remains as NULL. I run the query in MSMS and then immediately check the […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.