Syntax For WHERE Clause For Access Database
Oct 17, 2006
I have used this query statement with a SQL Server 2005 database and need to use something similar with an Access database:
SELECT products.*, Category AS Expr1
FROM products
WHERE (Category = @Category)
When I test this in a table adapter there is no preview due to lack of parameter. I seem to recall that Access uses different syntax in the WHERE filter clause (i.e., not @). Can someone help me out with this?
View 3 Replies
ADVERTISEMENT
Feb 26, 2008
I know how to access different tables on the same server by prefixingthe table with the database name. Is there anyway to prefix theserver name to link two tables across servers? Thanks.
View 2 Replies
View Related
Aug 9, 2007
MS SQL Server 2005 Express.
I'm trying to connect to Access DB (having System Database) via OPENROWSET.
Everything (client, server and access file) is on local drive.
This works (ODBC):
select *
from openrowset('MSDASQL',
'Driver={Microsoft Access Driver (*.mdb)};Dbq=C:MBK.mdb;SystemDB=C:SECURED.MDW;Uid=me;Pwd=pw;',
'select * from [Mbk]')
This works (Jet.OLEDB):
select *
from opendatasource('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:MBK.mdb;Jet OLEDBystem Database=C:SECURED.MDW;User ID=me;Password=pw;')
...Mbk
This won't work (Jet.OLEDB):
select *
from openrowset('Microsoft.Jet.OLEDB.4.0',
'MS Access;Database=C:MBK.mdb;System Database=C:SECURED.MDW;UID=me;PWD=pw;',
'select * from [Mbk]')
saying ... "Wrong argument".
This won't work (Jet.OLEDB):
select *
from openrowset('Microsoft.Jet.OLEDB.4.0',
'MS Access;Database=C:MBK.mdb;SystemDB=C:SECURED.MDW;UID=me;PWD=pw;',
'select * from [Mbk]')
saying ... "There are no permissions for usage of object C:MBK.mdb". It seems that it simply hasn't found system database file C:SECURED.MDW, cause when I change SystemDB=C:SECURED.MDW to something like BlahBlahBlah=C:SECURED.MDW the same message is shown.
So, what is the right syntax for stating System Database in OPENROWSET query string? And why 'System Database' won't work?
Thank you.
View 1 Replies
View Related
Sep 23, 2007
Ok I am tying to convert access syntax to Sql syntax to put it in a stored procedure or view..
Here is the part that I need to convert:
SELECT [2007_hours].proj_name, [2007_hours].task_name, [2007_hours].Employee,
IIf(Mid([task_name],1,3)='PTO','PTO_Holiday',
IIf(Mid([task_name],1,7)='Holiday','PTO_Holiday',
IIf(Mid([proj_name],1,9) In ('9900-2831','9900-2788'),'II Internal',
IIf(Mid([proj_name],1,9)='9900-2787','Sales',
IIf(Mid([proj_name],1,9)='9910-2799','Sales',
IIf(Mid([proj_name],1,9)='9920-2791','Sales',
)
)
)
)
) AS timeType, Sum([2007_hours].Hours) AS SumOfHours
from................
how can you convert it to sql syntax
I need to have a nested If statment which I can't do in sql (in sql I have to have select and from Together for example ( I can't do this in sql):
select ID, FName, LName
if(SUBSTRING(FirstName, 1, 4)= 'Mike')
Begin
Replace(FirstNam,'Mike','MikeTest')
if(SUBSTRING(LastName, 1, 4)= 'Kong')
Begin
Replace(LastNam,'Kong,'KongTest')
if(SUBSTRING(Address, 1, 4)= '1245')
Begin
.........
End
End
end
Case Statement might be the solution but i could not do it.
Your input will be appreciated
Thank you
View 5 Replies
View Related
May 14, 2007
<asp:SqlDataSource ID="productsUpdate" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringAccountType %>"
SelectCommand="SELECT [ProductID], [ProductName], [ImageTitle], [ImageData], [ImageMimeType] FROM [Products] WHERE [ProductID] = @ProductID"
UpdateCommand="UPDATE [Products] SET [ImageTitle] = Null, [ImageData] = Null, [ImageMimeType] = Null WHERE [ProductID] = @ProductID" InsertCommand="INSERT INTO [Products] ([ImageTitle], [ImageData], [ImageMimeType]) VALUES (@ImageTitle, @ImageData, @MimeType) WHERE ([ProductID] = @ProductID)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="ProductID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ImageTitle" />
<asp:Parameter Name="ImageData" Type="string" />
<asp:Parameter Name="MimeType" Type="string" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ImageTitle" Type="String" />
<asp:Parameter Name="ImageData" />
<asp:Parameter Name="MimeType" Type="String" />
</InsertParameters>
</asp:SqlDataSource> Hi Guys, new to development using visual studio and vb.net 2.0. and SQL express. Have a small problem.I have an update command which im using to change the values of a blob image table to NULL so that i can then insert a new image into the table. This works fine. My problem is that my insert statement has an error and i cant figure this out. if i dont add the where clause it works fine but inserts the new image into the table without the product data, i want to insert the new image into the existing product information. The error message i keep getting is "incorrect syntax near where"Any help would be greatly appreciatedThanks
View 7 Replies
View Related
Feb 6, 2005
I have the code below and the where clause is giving me errors, I have already setup FT Index, I think the error is lack of ' or " or "" or some kinda syntax pls help... as I can figure it out
I passed the word MBAISE
where CONTAINS(*, '+@searchstring+' )
Declare @myStatement varchar(8000)
Declare @LastRec int
Declare @FirstRec int
SELECT @FirstRec = (@CurrentPage - 1) * @PageSize
SELECT @LastRec =(@CurrentPage * @PageSize + 1 )
SELECT @myStatement = ' SELECT SalaryStatistical, EmployerID,JobLocation, location, SectorID
FROM #TEMP
where CONTAINS(*, '+@searchstring+' )
AND (LastLogin >= dateadd(d, -' + @HowManyDays + ', getdate())
AND (ID > '+ convert(varchar(20),@FirstRec) +')
AND (ID < '+convert(varchar(20),@LastRec) +')
AND (SalaryStatistical > '+ convert(varchar(20),@SalaryStatistical)+')
'
IF @JobLocation != @myzero
BEGIN
SELECT @myStatement = @myStatement + ' AND (JobLocation IN ('+convert(varchar(90),@JobLocation)+')) '
END
IF @sectorID != @myzero
BEGIN
SELECT @myStatement = @myStatement + ' AND (SectorID IN ('+convert(varchar(90),@sectorID)+')) '
END
SELECT @myStatement = @myStatement
print @myStatement
exec(@myStatement)
GO
View 1 Replies
View Related
Nov 6, 2007
I started reading a very informative book (Inside Microsoft SQL Server 2005: T-SQL Querying) that uses the following example.SELECT orderid, customerid,
COUNT(*) OVER(PARTITION BY customerid) AS num_orders
FROM dbo.Orders
WHERE customerid IS NOT NULL
AND orderid % 2 = 1;
Being new to T-SQL, I don't understand what is going on in the last line "orderid % 2 = 1". I tried searching "Books On Line" with no answer. Is there a good reference or textbook out there I can use to find the answers to specific syntax questions?
View 3 Replies
View Related
Jun 8, 2008
Hi all,I am a newbie to asp and have been using VWD to make a database for an assignment but I am having big problems trying to extract some data to a datalist view. I intend to use this page to display all information of hotel rooms. I know its probably really obvious to some of you but its driving me mad!!! Any help would be greatly appreciated. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim ds As New DataSet() Dim sGetRooms As String = "SELECT RoomID, RoomType, " _ & "RoomName FROM Rooms2 " _ & "WHERE RoomType LIKE @RoomType " _ & "ORDER BY RoomType" Dim sGetroomsizeandprice As String = "SELECT ID, RoomSize, RoomPrice, @RoomType " _ & "FROM roomprices JOIN Rooms2 ON Rooms2.ID = roomprices.ID " _ & "WHERE RoomType LIKE @RoomType " _ & "ORDER BY RoomPrice" Dim sConnect As String = ConfigurationManager.ConnectionStrings("White Sand's Hotel - Dan MahilConnectionString").ConnectionString Using con As New OleDbConnection(sConnect) Dim da As New OleDbDataAdapter(sGetRooms, con) Dim param As New OleDbParameter("RoomType", OleDbType.VarChar, 10) param.Value = Request.QueryString("RoomType") & "%" da.SelectCommand.Parameters.Add(param) Try da.Fill(ds, "Rooms2") da.SelectCommand.CommandText = sGetroomsizeandprice da.Fill(ds, "roomprices") Catch ex As Exception Label4.Text = "ERROR: " & ex.Message Exit Sub End Try End Using Dim pkcol As DataColumn = ds.Tables("Room2").Columns("RoomID") Dim fkcol As DataColumn = ds.Tables("roomprices").Columns("ID") Dim dr As New DataRelation("MenuLink", pkcol, fkcol) ds.Relations.Add(dr) DataList1.DataSource = ds DataList1.DataMember = "Rooms2" DataList1.DataBind() End Sub
View 2 Replies
View Related
Jan 11, 2005
Having problems rewriting my join condition using the "inner join" syntax.
My query, working with an intersection table:
SELECT Description, EmailAddress
FROM Accounts_Roles r, Accounts_Users u, Accounts_UserRoles ur
WHERE
r.RoleID = ur.RoleID
AND
u.UserID = ur.UserID
This works fine, but i want to write it using 'inner join' style, so I tried:
SELECT Description, EmailAddress
FROM Accounts_Roles r, Accounts_Users u
INNER JOIN Accounts_UserRoles ur
ON
r.RoleID = ur.RoleID
AND
u.UserID = ur.UserID
which gives me an error (The column prefix 'r' does not match with a table name or alias name used in the query.)
Any ideas as to how I'm screwing this up would be appreciated.
Thanks,
Gordon Z
View 3 Replies
View Related
Mar 26, 2008
What is the equivalent for INCLUDE clause (in Create index syntax) in SQL Server 2000.
SQL Server 2005 will support Include clause in Create index syntax . How to attain it in SQL Server 2000
Example : I have below query executable in SQL Server 2005
CREATE INDEX Index_Name ON mytable(col1 ASC) INCLUDE (name,id);
What is the equivalent for the above query in SQL server 2000
Thanks ,
Sushma
View 1 Replies
View Related
Nov 16, 2007
You know how you can go:
Code Block
where control_id in (11111,22222,33333,44444)
or
Code Block
where TextName in ('11111','22222','33333','44444')
and you can do this:
Code Block
where TextName like '11%' or TextName like '22%'
well how do you do this? Or can you... or can we right a function to do it... or are we just hosed writing like after like.
where TextName like in ('11%','22%',... and so on)? is anything like that possible?
or better yet
where TextName like in ( select substring(columnName, 1, 2) + '%' from whatever )
can you imagine the dynamics if that syntax actually worked?
Can a function be written to mimic this functionality? so I can do something like this:
where TextName = function('11%,22%,33%')
View 13 Replies
View Related
Aug 9, 2006
Can anyone tell me why the line highlighted in blue produces the following error when I try to run this stored proc? I know the parameters are set properly as I can see them when debugging the SP.
I'm using this type of approach as my application is using the objectdatasource with paging. I have a similar SP that doesn't have the CategoryId and PersonTypeId parameters and that works fine so it is the addition of these new params that has messed up the building of the WHERE clause
The Error is: "Syntax error converting the varchar value ' WHERE CategoryId = ' to a column of data type int."
Thanks
Neil
CREATE PROCEDURE dbo.GetPersonsByCategoryAndTypeByName (@CategoryId int, @PersonTypeId int, @FirstName varchar(50)=NULL, @FamilyName varchar(50)=NULL, @StartRow int, @PageSize int)
AS
Declare @WhereClause varchar(2000)Declare @OrderByClause varchar(255)Declare @SelectClause varchar(2000)
CREATE TABLE #tblPersons ( ID int IDENTITY PRIMARY KEY , PersonId int , TitleId int NULL , FirstName varchar (50) NULL , FamilyName varchar (50) NOT NULL , FullName varchar (120) NOT NULL , AltFamilyName varchar (50) NULL , Sex varchar (6) NULL , DateOfBirth datetime NULL , Age int NULL , DateOfDeath datetime NULL , CauseOfDeathId int NULL , Height int NULL , Weight int NULL , ABO varchar (3) NULL , RhD varchar (8) NULL , Comments varchar (2000) NULL , LocalIdNo varchar (20) NULL , NHSNo varchar (10) NULL , CHINo varchar (10) NULL , HospitalId int NULL , HospitalNo varchar (20) NULL , AltHospitalId int NULL , AltHospitalNo varchar (20) NULL , EthnicGroupId int NULL , CitizenshipId int NULL , NHSEntitlement bit NULL , HomePhoneNo varchar (12) NULL , WorkPhoneNo varchar (12) NULL , MobilePhoneNo varchar (12) NULL , CreatedBy varchar(40) NULL , DateCreated smalldatetime NULL , UpdatedBy varchar(40) NULL , DateLastUpdated smalldatetime NULL, UpdateId int )
SELECT @OrderByClause = ' ORDER BY FamilyName, FirstName'
SELECT @WhereClause = ' WHERE CategoryId = ' + @CategoryId + ' AND PersonTypeId = ' + @PersonTypeIdIf NOT @Firstname IS NULLBEGIN SELECT @WhereClause = @WhereClause + ' AND FirstName LIKE ISNULL(''%'+ @FirstName + '%'','''')'ENDIf NOT @FamilyName IS NULLBEGIN SELECT @WhereClause = @WhereClause + ' AND (FamilyName LIKE ISNULL(''%'+ @FamilyName + '%'','''') OR AltFamilyName LIKE ISNULL(''%'+ @FamilyName + '%'',''''))'END
Select @SelectClause = 'INSERT INTO #tblPersons( PersonId, TitleId, FirstName, FamilyName , FullName, AltFamilyName, Sex, DateOfBirth, Age, DateOfDeath, CauseOfDeathId, Height, Weight, ABO, RhD, Comments, LocalIdNo, NHSNo, CHINo, HospitalId, HospitalNo, AltHospitalId, AltHospitalNo, EthnicGroupId, CitizenshipId, NHSEntitlement, HomePhoneNo, WorkPhoneNo, MobilePhoneNo, CreatedBy, DateCreated, UpdatedBy, DateLastUpdated, UpdateId)
SELECT PersonId, TitleId, FirstName, FamilyName , FullName, AltFamilyName, Sex, DateOfBirth, Age, DateOfDeath, CauseOfDeathId, Height, Weight, ABO, RhD, Comments, LocalIdNo, NHSNo, CHINo, HospitalId, HospitalNo, AltHospitalId, AltHospitalNo, EthnicGroupId, CitizenshipId, NHSEntitlement, HomePhoneNo, WorkPhoneNo, MobilePhoneNo, CreatedBy, DateCreated, UpdatedBy, DateLastUpdated, UpdateId
FROM vw_GetPersonsByCategoryAndType '
EXEC (@SelectClause + @WhereClause +@OrderByClause)
View 1 Replies
View Related
Oct 29, 2015
I cannot seem to find the syntax to combine IN + CASE in a WHERE clause
WHERE
ses.BK_MS_SESSION <= '2015-03'
AND vis.CAT_DRAW_STATUS =
(CASE ses.BK_MS_SESSION
WHEN '2015-03' THEN vis.CAT_DRAW_STATUS
ELSE
CASE stat.BK_MS_VISIT_STATUS
WHEN 'T' THEN 'X'
ELSE vis.CAT_DRAW_STATUS
END
END
) IN ('D','R')
View 7 Replies
View Related
Aug 3, 2006
I am having this error when using execute query for CTE
Help will be appriciated
View 9 Replies
View Related
Apr 22, 2004
There is a JOIN syntax error in this SQL, but my slow brain cannot figure out where. I tried to join two queries, which had been successful. Problem occurred when I added second left join. Can anyone help?
PARAMETERS pstrFinYear Text ( 255 ), pintAdjMonth Long;
SELECT A.BudgetLineID, A.BudgetLine, B.NumIsDevelopBusinessInternationally, B.NumIsDeeperParticipation, B.NumIsNewExporter, B.NumProjects, C.NumCompanies, A.KMISReportOrder
FROM ( tblkpBudgetLine AS A
LEFT JOIN
[SELECT BudgetLineID, FinancialYear, SUM(IsDevelopBusinessInternationally) AS NumIsDevelopBusinessInternationally, SUM(IsDeeperParticipation) AS NumIsDeeperParticipation, (-1*SUM(AdjustedNewExpMonth=pintAdjMonth)) AS NumIsNewExporter, COUNT(ProjectID) AS NumProjects
FROM qryBoardReport_Actuals
WHERE FinancialYear=pstrFinYear
AND AdjustedProjectStartMonth=pintAdjMonth
GROUP BY BudgetLineID, FinancialYear]. AS B
ON (A.BudgetLineID=B.BudgetLineID) AND (A.FinancialYear=B.BudgetLine)
LEFT JOIN
[SELECT Z.BudgetLineID, Z.FinancialYear, Z.AdjustedProjectStartMonth, COUNT(Z.Company) AS NumCompanies
FROM [SELECT DISTINCT qryBoardReport_Actuals.BudgetLineID AS BudgetLineID, qryBoardReport_Actuals.FinancialYear AS
FinancialYear, qryBoardReport_Actuals.AdjustedProjectStartMonth, qryBoardReport_Actuals.CompanyID as Company
FROM qryBoardReport_Actuals
WHERE FinancialYear=pstrFinYear
AND AdjustedProjectStartMonth=pintAdjMonth
GROUP BY qryBoardReport_Actuals.FinancialYear, qryBoardReport_Actuals.BudgetLineID, qryBoardReport_Actuals.AdjustedProjectStartMonth, qryBoardReport_Actuals.CompanyID]. AS Z
GROUP BY FinancialYear, BudgetLineID, AdjustedProjectStartMonth] as C
ON (A.BudgetLineID=C.BudgetLineID) and (A.FinancialYear=C.FinancialYear))
WHERE A.FinancialYear=pstrFinYear
ORDER BY A.KMISReportOrder;
View 8 Replies
View Related
May 7, 2004
This runs in Access, but SQL Server 7 complains that BETWEEN is unrecognized. Can anyone help me? thanks
SELECT yearId, IIf(Date() BETWEEN [qrtOneStart] AND [qrtOneEnd],1, IIf(Date() BETWEEN [qrtTwoStart] AND [qrtTwoEnd], 2, IIf(Date() BETWEEN [qrtThreeStart] AND [qrtThreeEnd], 3, 4))) AS CurrentQrt, yearName
FROM tblYear
View 7 Replies
View Related
Aug 21, 2013
I am trying to convert a code from access Db to sql code?
II(Left([dbo_ClaimLosstype].[dscr],4)="Liab","D_Liab","D_Property"),
View 4 Replies
View Related
Apr 4, 2008
I created a couple of stored procedures. One of them (let's call it SP1) dumps information into a table and then calls another stored procedure (SP2) to put the info in a temp table in crosstab format. SP1 then displays the info from the temp table.
When I execute SP1 from Query Editor, everything works perfectly. No errors are returned and my data is displayed just as expected.
When I try to execute SP1 from MS Access's pass-through query, I get the following error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ','.(#102)[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'A'(#102)
I've found that the error occurs when the SP2 is called from within SP1. If it's working fine in Query Editor, shouldn't it work from MS Access? Any insights?
View 2 Replies
View Related
Sep 13, 2007
I am trying to get a SQL statement to work with both Access 2000 and SQL Server 2000.
The statement that works in SQL Server is:
---
UPDATE [myTable2]
SET
[myTable2].[FieldA] = 'Hello',
[myTable2].[FieldB] = 2,
[myTable2].[FieldC] = 'xxx',
[myTable2].[FieldD] = 0
FROM [myTable1] INNER JOIN
(myTable2 INNER JOIN [myTable3]
ON [myTable2].[FieldX]=[myTable2].[FieldY])
ON [myTable1].[FieldZ]=[myTable2].[FieldY]
WHERE ([myTable2].[FieldY]=1)
And ([myTable3].[FieldZ]='xxx');
---
(names have been changed to protect the innocent)
The statement that works in Access is:
---
UPDATE [myTable1] INNER JOIN
(myTable2 INNER JOIN [myTable3]
ON [myTable2].[FieldX]=[myTable2].[FieldY])
ON [myTable1].[FieldZ]=[myTable2].[FieldY]
SET
[myTable2].[FieldA] = 'Hello',
[myTable2].[FieldB] = 2,
[myTable2].[FieldC] = 'xxx',
[myTable2].[FieldD] = 0
WHERE ([myTable2].[FieldY]=1)
And ([myTable3].[FieldZ]='xxx');
---
It seems that neither will accept the other format. Can anyone suggest how I can rearrange the statement so that it works in both?
View 2 Replies
View Related
Sep 30, 2015
I am having trouble finding the correct syntax to access a variable. I have a variable defined in the Variables window: The variable name is formatedDate. The DataType is String.
I am successfully setting the value of the variable in a Execute SQL Task. The SQL is as follows:
SELECT LEFT(CONVERT(VARCHAR, MAX(ReportDate), 120), 10) as formatedDate
from DimReportDates
The Result Set is set to “Single Row” and properly set up.
No problem so far. I can see with a watch that the variable has the correct value, something like:
‘2015-09-30’
Now, in a subsequent step, a Data Flow Task, I want to access the variable. Actualy it is in the SQL statement of a OLE DB source in the Data Flow… I have the following:
Declare @sDate smalldatetime
SELECT @sDate = xxxxx
I have tried several things substituting xxxxx above, but nothing seems to work. One variation was
@[User::formatedDate])
Another was
((DT_WSTR, 10) @[User::formatedDate]).
I think I’m close, but just can’t get it. What is the correct syntax.
View 4 Replies
View Related
Apr 25, 2003
Where i try to create stored procedure in sql server 2000 using query analyzer i'm getting an error
'[Microsoft][ODBC SQL Server Driver]Syntax error or access violation'
and the same stored procedure if i try after some time without any changes it gets created..
how is wrong?
View 2 Replies
View Related
Apr 17, 2008
Hi guys! I am using SQL 2005 and I wonder why I am encountering the error "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" everytime I am trying to create stored procedure with temp table and table variable.
See my code below with temp table.
Any thoughts will be appreciated!
CREATE PROCEDURE DBO.SAMPLESP
(@DETAILS AS VARCHAR(8000),
@ID AS VARCHAR(15))
AS
BEGIN TRANSACTION
CREATE TABLE DBO.#TEMPTABLE
{
ASSET VARCHAR(50)
}
DECLARE @INSTINSERT AS NVARCHAR(4000)
SET @INSTINSERT= 'INSERT INTO #TEMPTABLE(ASSET)'
SET @INSTINSERT= @INSTINSERT+ @DETAILS
EXEC sp_ExecuteSQL @INSTINSERT
INSERT INTO InstDetail
(TrackNum, ASSETID)
SELECT @ID, A.ASSE
FROM #TEMPTABLE A
DROP TABLE #TEMPTABLE
IF @@ERROR != 0
BEGIN
ROLLBACK TRANSACTION
RAISERROR('There was an error in here', 11, 1)
RETURN
END
ELSE
COMMIT TRANSACTION
View 5 Replies
View Related
Aug 17, 2000
We have been asked to look into using stored procedures with SQL Server 7.0 as a way to speed up a clients site. 99% of all the articles I have read along with all the books all say Stored Procedure should be used whenever possible as opposed to putting the SQL in your ASP script. However one of my colleagues has been speaking to Microsoft and they said that that they were surprised that our client wanted to use Stored Procedures as this was the old method of database access and that now he should really consider using COM objects for data access as itis much faster. Has anyone got any views on this or know of any good aticles regarding this matter ?
View 1 Replies
View Related
Jun 10, 2015
I have recently upgraded to SQL2014 on Win2012. The Access front end program works fine.
But, previously created Excel reports with built in MS Queries now fail with the above error for users with MS 2013. The queries still work for users still using MS 2007.
I also cannot create any new queries and get the same error message. If I log on as myself on the domain to another PC with 2007 installed it works fine, so I don't think it is anything to do with AD groups or permissions.
View 6 Replies
View Related
Mar 25, 2008
I need to determine the following about the current authenticated Windows domain user who is trying to access a SQL Server via a trusted connection.
1 Has the current user been granted login access to the trusted SQL Server?
2 Has the current user been granted access to a specific database?
3 Is the current user a member of a specific database role such as (DB_ROLE_ADMINISTRATORS)?
Thanks,
Sean
View 6 Replies
View Related
Mar 19, 2007
I have database called 'test1' and when i use the code below im getting this error
Server: Msg 170, Level 15, State 1, Line 9
Line 11: Incorrect syntax near '@dbName'.
plz help, here is the code
DECLARE @dbName varchar(50)
DECLARE @index int
SET @index = 1
SET @dbName ='test'
set @dbName = @dbName + CAST(@index as varchar)
use @dbName
View 14 Replies
View Related
Jul 29, 2013
Still having a problem with my SQL WHERE clause…
I have three variables on an Excel form that connects to a Teradata database. The first variable is a date format (DateworkedF and DateworkedT) the other two are text fields. (StatusX and ErrorTypeX)
I want to be able to search on any or all of these fields. (If the field is blank return all values)
Query = "SEL SRN_ACCT_NUM, QUEUE_NAME, ERROR_TYPE, SUB_ERROR_TYPE, DATE_WORKED, MONTH_WORKED, DATE_APPLICATION_RECEIVED, ASSOC_WORKED, ACCT_ID, STATUS, COMMENTS, REVIEWED_IND, REVIEWED_AGENT, LOAD_DT " & _
"FROM UD402.JD_MCP_MASTER WHERE " & _
"(DATE_WORKED >= #" & DateworkedF & "# Or #" & DateworkedF & "# IS NULL)" & _
"AND (DATE_WORKED <= #" & DateworkedT & "# Or #" & DateworkedT & "# IS NULL)" & _
"AND (STATUS = '" & StatusX & "' OR '" & StatusX & "' IS NULL)" & _
"AND (ERROR_TYPE = '" & ErrorTypeX & "' or '" & ErrorTypeX & "' IS NULL);"
View 5 Replies
View Related
Jan 23, 2008
Hi,
I'm having an SSIS package which gives the following error when executed :
Error: 0xC002F210 at Create Linked Server, Execute SQL Task: Executing the query "exec (?)" failed with the following error: "Syntax error or access violation". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.Task failed: Create Linked Server
The package has a single Execute SQL task with the properties listed below :
General Properties
Result Set : None
ConnectionType : OLEDB
Connection : Connected to a Local Database (DB1)
SQLSourceType : Direct Input
SQL Statement : exec(?)
IsQueryStorePro : False
BypassPrepare : False
Parameter Mapping Properties
variableName Direction DataType ParameterName
User::AddLinkSql Input Varchar 0
'AddLinkSql' is a global variable of package scope of type string with the value
Exec sp_AddLinkedServer 'Srv1','','SQLOLEDB.1',@DataSrc='localhost',@catalog ='DB1'
When I try to execute the Query task, it fails with the above error. Also, the above the sql statement cannot be parsed and gives error "The query failed to parse. Syntax or access violation"
I would like to add that the above package was migrated from DTS, where it runs without any error, eventhough
it gives the same parse error message.
I would appreciate if anybody can help me out of this issue by suggeting where the problem is.
Thanks in Advance.
View 12 Replies
View Related
Feb 5, 2007
I developed a database with Access 2003 and everything was working good until my tech came in and reformated my hard drive and install a new Ghost image that met our company standards.
Now I cannot go in and make any changes to any of the tables, queries and forms. All of this started when a new Ghost image was installed on my pc.
The message I get when I try to open my database is "You do not have permission to run "tblSwitchboard." I get the same error message when I try to do anything at all on the database.
I am at a loss as to what to do. Please help.
View 1 Replies
View Related
Sep 29, 2005
Can someone tell me if this is the correct syntax for connecting to a
sql database thats on a server differnt then the application.
(vb - web config file)
<connectionStrings>
<add name="MyDbConn"
connectionString="server=24.243.45.23;user
id=Admin;password=jkjd;database='test';"
providerName="System.Data.SqlClient" />
</connectionStrings>
It works when I use localhost instead of the ip but I need to access an
sql database on another server and it doenst connect. It may not be my
code but I wanted to clarify before I spend to much time messing with
my sql settings. Thanks
View 2 Replies
View Related
Apr 4, 2001
I'm attempting to alter a database by removing one of two log files. I have truncated both log files successfully and the database has no processes but I get an error stating file cannot be removed because it is not empty. Help
View 2 Replies
View Related
Jan 7, 2007
create from dbo.fromExampleasfrom dbo.Customers cjoin dbo.Invoices ion c.CustomerID = i.CustomerIDnow you can use it as follows:select c.CustomerID, i.InvoiceNofrom dbo.fromExampleI find I reuse FROM clauses alotand reusing a "base query" requires writing a very large and cumbersomeselect clause
View 6 Replies
View Related