SQL Server stored procedure Nullable parameter

It looks like you’re passing in Null for every argument except for PropertyValueID and DropDownOptionID, right? I don’t think any of your IF statements will fire if only these two values are not-null. In short, I think you have a logic error. Other than that, I would suggest two things… First, instead of testing for … Read more

Getting data from stored procedure with Entity Framework

Use the following steps to solve this issue: You need to Import the stored procedure as a Function. Right-click on the workspace area of your Entity model and choose Add -> Function Import. In the Add Function Import dialog, enter the name you want your stored procedure to be referred to in your model for … Read more

Could not find server ‘server name’ in sys.servers. SQL Server 2014

At first check out that your linked server is in the list by this query select name from sys.servers If it not exists then try to add to the linked server EXEC sp_addlinkedserver @server=”SERVER_NAME” –or may be server ip address After that login to that linked server by EXEC sp_addlinkedsrvlogin ‘SERVER_NAME’ ,’false’ ,NULL ,’USER_NAME’ ,’PASSWORD’ … Read more

Dynamic order direction

You could have two near-identical ORDER BY items, one ASC and one DESC, and extend your CASE statement to make one or other of them always equal a single value: ORDER BY CASE WHEN @OrderDirection = 0 THEN 1 ELSE CASE WHEN @OrderByColumn = ‘AddedDate’ THEN CONVERT(varchar(50), AddedDate) WHEN @OrderByColumn = ‘Visible’ THEN CONVERT(varchar(2), Visible) … Read more

Loop through all the rows of a temp table and call a stored procedure for each row

you could use a cursor: DECLARE @id int DECLARE @pass varchar(100) DECLARE cur CURSOR FOR SELECT Id, Password FROM @temp OPEN cur FETCH NEXT FROM cur INTO @id, @pass WHILE @@FETCH_STATUS = 0 BEGIN EXEC mysp @id, @pass … — call your sp here FETCH NEXT FROM cur INTO @id, @pass END CLOSE cur DEALLOCATE … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)