Execute SELECT-only SQL queries against SAP tables and CDS views with comprehensive security validation. Use for querying data, previewing table contents, testing CDS views, or exploring SAP data. Blocks DML/DDL operations for safety. Keywords: query data, SELECT, preview table, CDS query, data exploration, SQL query, table data, view data
Execute SELECT-only SQL queries against SAP tables and CDS views using the MCP data_preview tool.
Use this skill when you need to:
This tool enforces strict security:
Why these restrictions:
| Type | Description | Example |
|---|---|---|
ddic | Database tables, transparent tables | MARA, VBAK, ZCUSTOMER |
cds | CDS views and CDS view entities | I_SalesOrder, ZI_Booking |
object_name: Name of table or CDS view to querysql_query: SELECT statement (validated for safety)object_type: ddic (default) or cdsmax_rows: Maximum rows to return (1-1000, default: 100)Automatic validation checks:
Rejected query examples:
❌ "SELECT * FROM mara; DELETE FROM mara"
❌ "INSERT INTO table VALUES (...)"
❌ "UPDATE table SET field = value"
❌ "DROP TABLE ztable"
❌ "SELECT * FROM mara -- comment"
Accepted query examples:
✅ "SELECT * FROM mara"
✅ "SELECT matnr, mtart FROM mara WHERE mtart = 'FERT'"
✅ "SELECT TOP 10 * FROM vbak"
✅ "SELECT * FROM I_SalesOrder WHERE SalesOrderType = 'OR'"
Returns structured JSON:
{
"success": true,
"object_name": "MARA",
"object_type": "ddic",
"row_count": 15,
"max_rows": 100,
"columns": [
{
"name": "MATNR",
"type": "CHAR",
"length": 40,
"description": "Material Number"
}
],
"rows": [
{
"MATNR": "000000000000000001",
"MTART": "FERT",
"MATKL": "001"
}
]
}
Preview table contents:
Show me the first 10 rows from table MARA
Query with filter:
Get all sales orders from table VBAK where order type is 'OR'
CDS view query:
Query CDS view I_SalesOrder for orders created in 2024
Specific fields:
Show material number and description from MARA for finished goods
Join exploration:
Query ZI_BOOKING to see customer and flight associations
Data validation:
After creating ZI_CUSTOMER, preview the data to verify associations work
SELECT * FROM table_name
Purpose: Quick overview of table structure and data
SELECT TOP 10 * FROM table_name
Purpose: Sample data without overwhelming output
SELECT field1, field2, field3 FROM table_name
Purpose: Focus on relevant columns
SELECT * FROM table_name WHERE field = 'value'
Purpose: Narrow down to relevant records
SELECT * FROM table_name ORDER BY field DESC
Purpose: See newest/highest/sorted data first
SELECT * FROM cds_view( parameter = 'value' )
Purpose: Test CDS view parameters
This is step 4 in the research-query workflow:
Use SAP documentation tools → Identify relevant table/CDS name
Search SAP Help for "sales order data model"
Result: VBAK, VBAP tables or I_SalesOrder CDS
Use GetObjectInfo → Retrieve metadata/structure
Get object info for I_SalesOrder
Result: Field definitions, associations, annotations
AI formulates SQL query → Based on structure and requirement
AI: "Based on fields, query should be:
SELECT SalesOrder, Customer, CreationDate
FROM I_SalesOrder
WHERE CreationDate >= '2024-01-01'"
Execute with data_preview → Run the query
Execute query on I_SalesOrder
Result: Actual data matching criteria
create_ai_object → Create CDS viewactivate_object → Activate and check syntaxdata_preview → Test CDS view returns expected datasearch_object → Find relevant tables/viewsget_object_info → Understand structuredata_preview → Explore actual dataWhen Copilot uses this skill, expect:
Data exploration workflow:
search_object → Find tables/viewsget_object_info → Understand structuredata_preview → See actual dataCDS development workflow:
sap_help_search → Research CDS patternscreate_ai_object → Create CDS viewdata_preview → Test CDS viewchange_ai_object → Fix issues if founddata_preview to verifyValidation workflow:
create_ai_object → Create objectget_atc_results → Check code qualitydata_preview → Validate data correctnesschange_ai_object if issues foundQuery: "SELECT TOP 100 * FROM mara"
Use: See what material master data looks like
Query: "SELECT * FROM ZI_BOOKING"
Use: Verify newly created CDS view returns data
Query: "SELECT * FROM vbak WHERE erdat >= '20240101'"
Use: Test date filter works correctly
Query: "SELECT booking_id, customer_id, customer._name FROM ZI_BOOKING"
Use: Verify CDS association to customer works
Query: "SELECT DISTINCT mtart FROM mara"
Use: Find all material types in system
Query: "SELECT COUNT(*) as record_count FROM table"
Use: Check table size
Common errors and fixes:
| Error | Cause | Fix |
|---|---|---|
| SQL validation failed | DML/DDL in query | Use SELECT only |
| Object not found | Wrong table name | Check name with search_object |
| Authorization error | No read access | Request authorization or use different table |
| SQL syntax error | Invalid SQL | Check SAP SQL syntax |
| Field not found | Wrong field name | Use get_object_info to check fields |
SAP authorization applies:
Authorization errors:
Error: No authorization for table MARA
Solution: Request authorization from SAP Basis team
Workaround: Use CDS views with appropriate DCL
SAP HANA SQL features (S/4HANA):
Traditional SQL features (ECC):
Consult SAP documentation for specific SQL capabilities of your system.
What this tool CANNOT do:
When you need data modification:
Important reminders: